400 Part III (Web hosting script) . Document Objects Reference About
January 24th, 2008400 Part III . Document Objects Reference About this object In object models that reveal HTML element objects, the BODY element object is the primary container of the content that visitors see on the page. The BODY contains all rendered HTML. This special place in the node hierarchy gives the BODY object some special powers, especially in the IE object model. As if to signify the special relationship, both the IE and W3C object models provide the same shortcut reference to the BODY element: document.body. As a first- class HTML element object (as evidenced by the long lists of properties, methods, and event handlers covered in Chapter 15), you are also free to use other syntaxes to reach the BODY element. You are certainly familiar with several BODY element attributes that govern body-wide content appearance, such as link colors (in three states) and background (color or image). But IE and NN (and the W3C so far) have some very different ideas about the BODY element s role in scripting documents. Many methods and properties that NN considers to be the domain of the window (for example, scrolling, inside window dimensions, and so forth), IE puts into the hands of the BODY element object. Therefore, while NN scrolls the window (and whatever it may contain), IE scrolls the body (inside whatever window it lives). And because the BODY element fills the entire viewable area of a browser window or frame, that viewable rectangle is determined in IE by the body s scrollHeightand scrollWidth properties, whereas NN4+ features window.innerHeight and window.innerWidth properties. This distinction is important to point out because when you are scripting window- or document-wide appearance factors, you may have to look for properties and methods for the window or BODY element object, depending on your target browser(s). Note Use caution when referencing the document.body object while the page is loading. The object may not officially exist until the page has completely loaded. If you need to set some initial properties via scripting, do so in response to the onLoad event handler located in the
tag. Attempts at setting BODY element object properties in immediate scripts inside the HEAD element may result in error messages about the object not being found. Properties aLink bgColor link text vLink Value: Hexadecimal triplet or color name string Read/Write document.body.aLinkVisit our web design programs services for an affordable and reliable webhost to suit all your needs.