| Previous Topic | Tutorial Table of Contents | Next Topic |
The Document ObjectThe document object does not have any event handlers defined for its use. All event handlers that can be registered in the <body> tag are window object handlers (see the event handler table).
Among the important properties of the document object are alinkcolor,
vlinkcolor, linkcolor, bgcolor and fgcolor
My fade-in script shows an example of changing the
bgcolor property.
The document object is also the controller of the cookie property of browsers, but I will
not be discussing cookies in this tutorial. For a very thorough tutorial on cookies,
visit chapter
19 of the online book
Using JavaScript.
Probably the most frequent use of the document object is for writing new text to a page
or frame. This is done with the three document methods:
document.open()
These three methods are used in combination to open a data stream to a document, write new
content and then close the data stream.
A simple use of these is to place them in your page outside a function so that they
execute while your page is loading.
For example, here's a simple bit of code to demonstrate:
<html> Click here to see how this bit of code works. < More typically, however, document.write() is used to overwrite a page or a frame with new information. One example of this would be a two-frame web page that had a constant frame and a variable frame. The constant frame might have a selection list from which you could select an item of interest. When an item was chosen, document.write() would be used to write information (and/or images) about that item in the variable content frame. |
| Previous Topic | Tutorial Table of Contents | Next Topic |