The W3C abstract states: "The Document Object Model provides a standard set of objects for representing HTML and XML documents, a standard model of how these objects can be combined, and a standard interface for accessing and manipulating them. Vendors can support the DOM as an interface to their proprietary data structures and APIs, and content authors can write to the standard DOM interfaces rather than product-specific APIs, thus increasing interoperability on the Web." 
The W3C defines DOM Level 1 to create an industry standard for all browsers, fully supported by Netscape 6 and Internet Explorer 5 and 6. The standard consists of two parts : the first defines how to navigate and manipulate the HTML and XML structure for the core objects, properties, and methods; the second defines a set of objects strictly related to HTML. In addition to DOM Level 1, there are two other levels, still in progress. What all that boils down to is that the DOM specifies a standard set of objects that will work with HTML and XML documents no matter what browser, no matter what scripting language.
Example 11.1 shows an HTML document and how it is represented structurally.
(The HTML Document) <html> <head> <title>My Page</title> </head> <body> <h1>Level 1</h1> <h2>Level 2</h2> <h3>Level 3</h3> </body> </html> (The DOM as a Tree)
We discussed the window as part of the browser object model in the last chapter. The DOM is concerned only with those nodes that make up the document object. Documents contain text, images, forms, links, etc. The most commonly used object is the document object . Subordinate to the document object are another set of objects, its children:
Figure 11.1. The document model.
Revisiting the Dot Syntax
11.1.2 The Document Itself
The document object is a property of the window object, and if the window is partitioned into frames (subwindows), each frame is a property of the window object.
As stated before, because the window object is at the top of the hierarchy, any objects just below it, such as the document or location objects, are window properties and the word window is not required; thus, specifying window.document.bgColor is the same as document.bgColor.
The syntax for describing the background color ( bgcolor ) property for a document object is shown in the following example:
document.bgColor = "yellow";
The document object is defined when the HTML <body> tag is encountered on the page and stays in existence until the page is unloaded, and the <body> tag has a number of attributes that define the appearance of the page. The document object has properties that correspond to the HTML <body> tag attributes, as shown in Tables 11.1 and 11.2. The properties of the document object are shown in the output of Example 11.2. (See Chapter 12, "Handling Events," for events that are associated with the <body> tag.)
Table 11.1. HTML <body> tag attributes.
Table 11.2. Some document object properties.
Figure 11.2. Using the for/in loop to display the properties of the document object.
The document Object Methods
The document object has methods to tell the object how to behave or what to do. Table 11.3 lists these methods. We have used the write() and writeln () methods throughout this text to send output to the screen dynamically, as shown below:
Methods, like properties, use the dot syntax to define the object they are manipulating; for instance, document.clear() or window. open (). (The parentheses differentiate a method from a property.)
Table 11.3. Methods of the document object.
When you open a new document, the current document will be replaced with a new document and all of its content overwritten. Example 11.4 opens a new document in an existing frame. The original text in the document is overwritten. After the document is opened, it must be closed.