DOM API - The "document" Object

This section provides a quick description of the 'document' object of the DOM API. A tutorial example is provided on building a simple HTML document with the 'document' object.

IE browser provides the DOM (Document Object Model) API (Application Programming Interface) to allow VBScript codes to interact with the browser and the HTML document.

The most commonly used object in the DOM API is the "document" object, which has the following features:

To illustrate some nice features of the "document" object, I wrote this VBScript tutorial example:

<html>
<!-- Document_Object.html
 - Copyright (c) 2015, HerongYang.com, All Rights Reserved.
-->
<head>
<title>Document Object</title>
<script type="text/vbscript">
function buildDocument()
   ' Building a <p> tag
   dim paragraph 
   set paragraph = document.createElement("p")
   dim text
   set text = document.createTextNode("Hello World!")
   paragraph.appendChild(text)

   ' Inserting the <p> tag
   document.body.appendChild(paragraph)
   document.body.bgColor = "lightblue"
end function
</script>
</head>
<body onLoad="buildDocument()"/>
</html>

If you run this VBScript page in a browser, you will see the "Hello World!" paragraph with light blue background.

For more tutorial examples on the "document" object, see the DOM API chapters in this book.

Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 Numeric Comparison Operations and Logical Operations

 String Operations - Concatenation and Comparison

 Variable Declaration and Assignment Statement

 Expression and Order of Operation Precedence

 Statement Syntax and Statement Types

 Array Data Type and Related Statements

 Array References and Array Assignment Statements

 Conditional Statements - "If ... Then" and "Select Case"

 Loop Statements - "For", "While", and "Do"

 "Function" and "Sub" Procedures

 Built-in Functions

 Inspecting Variables Received in Procedures

 Error Handling Flag and the "Err" Object

 Regular Expression Pattern Match and Replacement

 scrrun.dll - Scripting Runtime DLL Library

 Creating Your Own Classes

IE Web Browser Supporting VBScript

 VBScript Support in IE Web Browsers

 Including VBScript Codes with HTML "script" Tags

 Including VBScript Codes as External Files

DOM API - The "document" Object

 DOM API - The "window" Object

 Event Listeners and Objects

 'vbscript:' Pseudo-URL Addresses

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)

 References

 PDF Printing Version