Chapter 6
The HTML Document
The structure, contents, and style of an HTML document are exposed through the document property on the window. The document property returns an object that encapsulates all the information about the document. The document object is the most important and powerful object of the Dynamic HTML object model. Through this object, all elements contained in the document can fire events and can be accessed and modified by scripts, allowing you to create a dynamic document.
The document object's collections and the corresponding HTML elements.
The elements in the HTML document are exposed through a set of collections on the document object. The contents of the document are accessible through these elements and through a textRange object. Both techniques allow you to access and change the contents. The style of the document is exposed through the stylesheets collection.
Our discussion of these issues will span several chapters. This chapter begins the discussion by covering the following topics:
- Referencing the document object
The document object is a property of the window. This section shows you how to access the HTML document contained within the current window as well as documents displayed in other windows.
- Changing the Document's Colors
The document object exposes properties for manipulating the color of the text and background on the page. These properties are compatible with the existing object model implementations in Netscape Navigator and Microsoft Internet Explorer 3.0.
The Color SelectorIE4 Demo is a simple demonstration of the document's color properties.
- Accessing meta information about the document
- Modifying the HTML stream
The document object exposes methods for manipulating the HTML stream while the page is loading. These methods work only while a page is rendering and are not used to modify a page once it is loaded-separate objects and methods are exposed for this purpose.