HTML and CSS Reference
In-Depth Information
the window , because JavaScript knows that the window is at the top of the tree. Instead of
saying window.document.bgcolor , you can simply say document.bgcolor .
11.2.1 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.
Every window (or frame) contains a document object that corresponds to the HTML
document shown in the window. This object corresponds mainly to the body of the doc-
ument—that is, what is inserted between the <body></body> tags. JavaScript programs
manipulate this object to bring life to otherwise dead, static pages. Because the document
object is below the window object, the document object can be represented as a property
of the window by saying window.document . The forms object is an array of objects below
the document object, so the forms object is a property of the document object and is rep-
resented as window.document.forms[] .
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";
Document Properties. The document object is defined when the HTML <body> tag is
encountered on the page and stays in existence until the page exits. The <body> tag has a
number of attributes that define the appearance of the page. The document object has prop-
erties 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 13, “Handling Events,” for events that are associated with the <body> tag.)
Table 11.1 HTML <body> Tag Attributes
Attribute
What It Specifies
alink
Color of an active link; that is, while the mouse is on the link.
background
URL of a background image.
bgcolor
Background color of the page.
fgcolor
Text or foreground color.
link
Color of an unvisited link.
vlink
Color of a visited link.
 
 
Search WWH ::




Custom Search