Click here to Skip to main content
13,900,891 members
Click here to Skip to main content
Add your own
alternative version


51 bookmarked
Posted 8 May 2001

Refreshing only part of your Web Page

, 8 May 2001
Rate this:
Please Sign up or sign in to vote.
An article on refreshing objects on your Web Page without having to refresh the entire page

Top Ten Picture


I needed to make a portion of Web Page to refresh without refreshing the entire page. Everytime I tried, it would always refresh the entire page. I got very frustrated, then I read an article from CodeProject (CodeProject Discussion Boards) and thought I would talk to Uwe Kein (the Author) about this. His suggestion was to use Remote Scripting which by the articles I read was the way to go. Unfortunately, my company didn't have that installed on their dev or production systems. I couldn't wait for them, so I tried scriptlets. After a lot of trial and error, I got it to work. I am writing this article to try and help anyone else in this situation.

What will this do for you?

Show you how to refresh a scriptlet every second using a timer inside the scriptlet. This example uses a DNS-Connection-less (meaning you don't have to create a System DNS entry through ODBC) way to access the MS-Access database, but you can adapt it to any other by changing the ConnectionString (see below formats):

//Build the connection string
//for Access Database (on Server):
//ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" &_
//                   "Data Source=\\\\SERVER\\Share\\directory\\TopTen.mdb";
//for Access Database (on local drive):
//ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" &_
//                   "Data Source=C:\\Database\\TopTen.mdb";

I have included an Access2000 Database called/Located at C:\TopTen\TopTen.mdb to use for the example, or you can use the text file TopTen.txt which will create a Table, User Login, User Role, Primary Key, and Insert ten rows for an SQL 7.x database.

Note: if you want to use ASP (server calls) code, write it as a "JavaScript" function and use RUNAT=server in the <SCRIPT> Tag.

What are scriptlets

Scriptlets are HTML pages that heavily exploit the DHTML object model. Here is how simple it is...write a normal HTML file. Create an function for the scriptlet called "CreatePage". Now, create a "new" object called public_description and assign it the result of the function. This function works as a the constructor of the scriptlet object. In one sense, the public_description variable is like a header file for a C++ class. It defines all the properties and methods that the scriptlet exposes. See the example below:

// declare the object interface (constructor)
public_description = new CreatePage();
var InScriptlet = (typeof(window.external.version) == "string");

// set some variables
mEnabled = 1;
mTimer = 0

function CreatePage() {
	this.Refresh = Refresh;
	this.Enable = Enable;

Since a scriptlet is an HTML or ASP page (and can also be displayed as a stand-alone document), you might occasionally incur a system error due to a property or a method that IE 4 (or higher) doesn't find. This only happens if your scriptlet attempts to access its parent environment. To work around this you need a way to detect whether a given page is viewed as a scriptlet or not. Since the external object gets initialized if, and only if, an HTML page is running as a scriptlet, provide a boolean variable as a safeguard and access the external object only when it is absolutely safe to do so.

var InScriptlet = (typeof(window.external.version) == "string");

The variable above InScriptlet will contain True or False, according to the type of the property external.version (current version of the scriptlet engine). You can now use InScriptlet in your code to determine how the page is being viewed.

The way to get it to refresh is either by calling the "Refresh" method or by setting a timer in the window.onLoad event:

mTimer = window.setInterval( "DoUpdatePage()", 1000, "VBScript" )

Since both ActiveX controls and scriptlets are inserted through the same tag <OBJECT>, you need to make the browser distinguish between them (see below).

ActiveX Control:

  <param name="...">



That's it...let me know what you think!


For a good book/examples check out Scriptlets and for the examples in the book, go to Examples


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Dan Madden
Product Manager
Germany Germany
I have been programming (as a hobby) for 20+ years (Unix C, Scripting, VB, C/C++, C#). I am getting too old to talk about it and been in the Security line of work (both Military/Civilian) for 25+ years.

You may also be interested in...


Comments and Discussions Pin
abhay_smpr24-Aug-06 19:49
memberabhay_smpr24-Aug-06 19:49 
QuestionHow i Refresh only part of web page Pin
22-Mar-05 1:50
suss22-Mar-05 1:50 
Generalserver side database Pin
SWARYA29-Feb-04 22:07
memberSWARYA29-Feb-04 22:07 
GeneralFunctions in ASP Pin
20-Jun-02 17:33
suss20-Jun-02 17:33 
Generals Pin
17-Aug-01 20:54
suss17-Aug-01 20:54 
GeneralRe: s Pin
Member 1362982222-Apr-18 16:43
memberMember 1362982222-Apr-18 16:43 
GeneralOne more way!!! Pin
Dhandapani Ammasai10-May-01 12:44
memberDhandapani Ammasai10-May-01 12:44 
GeneralRe: One more way!!! Pin
Dan Madden10-May-01 17:23
memberDan Madden10-May-01 17:23 
GeneralRe: One more way!!! Pin
Dhandapani Ammasai10-May-01 17:40
memberDhandapani Ammasai10-May-01 17:40 
GeneralRe: One more way!!! Pin
Dan Madden10-May-01 17:53
memberDan Madden10-May-01 17:53 
GeneralRe: One more way!!! Pin
Dhandapani Ammasai10-May-01 18:12
memberDhandapani Ammasai10-May-01 18:12 
GeneralRe: One more way!!! Pin
Dan Madden10-May-01 18:32
memberDan Madden10-May-01 18:32 
GeneralRe: One more way!!! Pin
28-May-01 19:57
suss28-May-01 19:57 
GeneralRe: One more way!!! Pin
Dan Madden28-May-01 20:07
memberDan Madden28-May-01 20:07 
GeneralRe: One more way!!! Pin
9-Nov-01 12:05
suss9-Nov-01 12:05 
GeneralRe: One more way!!! Pin
Vasudevan Deepak Kumar30-Nov-05 22:15
memberVasudevan Deepak Kumar30-Nov-05 22:15 
GeneralAn easier way... Pin
9-May-01 2:19
suss9-May-01 2:19 
GeneralRe: An easier way... Pin
Dan Madden9-May-01 9:27
memberDan Madden9-May-01 9:27 
GeneralRe: An easier way... Pin
11-May-01 2:34
suss11-May-01 2:34 
GeneralRe: An easier way... Pin
Dan Madden14-May-01 2:01
memberDan Madden14-May-01 2:01 
GeneralRe: An easier way... Pin
24-Apr-02 21:56
suss24-Apr-02 21:56 
GeneralRe: An easier way... Pin
Anonymous30-Apr-04 3:27
memberAnonymous30-Apr-04 3:27 
Generalnot very efficient Pin
8-May-01 23:23
suss8-May-01 23:23 
GeneralRe: not very efficient Pin
Steven J. Ackerman9-May-01 6:01
memberSteven J. Ackerman9-May-01 6:01 
GeneralRe: not very efficient Pin
9-May-01 21:08
suss9-May-01 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190306.1 | Last Updated 9 May 2001
Article Copyright 2001 by Dan Madden
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid