Many HTML elements can also be treated as Internet Explorer Scripting Objects. In order to work effectively with VBScript and HTML elements and to see how they can intermingle, you need to understand the Internet Explorer Scripting Object Model.
The Object Model is pretty straightforward, if you understand the object-ness of Visual Basic. At the top of the IE Object Model hierarchy is the Window object, which is the parent to all other objects. This arrangement is similar to the Form-Custom Control architecture in Visual Basic (see Figure 7.17). Object referencing works the same in VBScript as in VB:
parent_object.child_object.property = somevalueBe advised that variable scope and types are bit tricky. The scope of VBScript variables is described as procedure scope and script scope. What procedure and script scope means is that the variable can be seen only in the sub or function if it is declared inside the procedure. If it is declared outside a procedure, it has script wide scope. A script in this case means an HTML page. All variables in VBScript are of the data type Variant but you must watch the subtype.
The Internet Explorer Scripting Object Model Hierarchy
The following sections are a brief description of the objects in the IE Object Model, The files used in the listings can be found in the /HTML directory of this project, and on the CD-ROM that comes with this book.
Window
The Window is the object at the top of the IE Scripting Object Model. Operationally, it is the Internet Explorer.
Methods: alert, confirm, prompt, open, close, setTimeout, clearTimeout, navigate
Events: onLoad, onUnload
Properties: name, parent, opener, self, top, location, defaultStatus, status, frames, history, navigator, document
Listing 7.16 - HELLO.HTM - To send a message to a user, you can use the Window objects alert method.
<HTML><HEAD> <TITLE>Hello</TITLE> <SCRIPT LANGUAGE=VBScript> <!-- Sub window_onLoad window.Alert "Hello World" End Sub --> </SCRIPT> </HEAD>