This documentation is archived and is not being maintained.

Dynamic HTML (DHTML) Scriptlets

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

You can create custom reusable objects for Web pages by using DHTML scriptlets. DHTML scriptlets are Web pages in which script procedures have been written according to certain conventions so that these procedures behave similar to methods and properties of the scriptlet. Scriptlets are supported in Internet Explorer version 4.0 and later. You can build scriptlets in either Microsoft® Visual Basic® Scripting Edition (VBScript) or Microsoft® JScript®.

Scriptlets can be script only, or they can have a user interface component in addition to script. You can include a scriptlet in the HTML for other pages to add the functionality that the scriptlet provides to those pages. By building scriptlets, you can componentize the process of developing Web pages in much the same way that you componentize applications with custom objects in Microsoft® Visual Basic® for Applications (VBA).

You refer to a scriptlet in an <OBJECT> tag in the HTML code for the page in which you want to use it. The following HTML code, shows how to refer to the Scriptlet.htm sample file. Note that the DATA attribute contains the name of the scriptlet file, Scriptlet.htm; this is comparable to the name of a class in VBA. The name for the scriptlet, as it is referred to within the script, is scrltDateCode; this name is comparable to the variable that you use to represent an instance of a class in VBA.

<OBJECT ID="scrltDateCode" 
STYLE=  "position:absolute;

The scriptlet file itself, Scriptlet.htm, contains script procedures that behave similar to methods and properties. The following procedure defines the GetYear property for the scriptlet:

Function public_get_GetYear()
' Return the current year.
   public_get_GetYear = Year(Date())
End Function

When the scriptlet has been included in a Web page by using the <OBJECT> tag, script in that Web page can call methods and properties of the scriptlet. For example, the following script fragment returns the value of the scriptlet's GetYear property and stores it in a variable.

Dim strCurrentYear

strCurrentYear = scrltDateCode.GetYear      

For more information about creating and using scriptlets, see the Microsoft Scripting Technologies Web site at

See Also

Why Build Your Own Objects? | Basic Class Concepts | Creating Property Procedures | Creating Events and Event Procedures | Extending Objects Through Interfaces | Designing Object Models | Creating Custom Objects for Web Pages | Using Web Technologies with Office XP | Using Web Technologies