15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The Document<br />

and Body<br />

Objects<br />

(Chapter 18)<br />

To include coverage of the document object and BODY element<br />

object in the same chapter is logical, provided you<br />

don’t fall into a conceptual trap that has been set during the<br />

evolution of document object models. The document object<br />

has been with us since the beginning. Even though it is an<br />

abstract object (that is to say, the object exists simply by virtue<br />

of a page loading into the browser, rather than associated with<br />

any HTML tag), a number of its properties reflect attributes<br />

that are defined in a page’s tag. For instance, the properties<br />

for link colors and background images, whose behaviors<br />

are set in BODY element attributes, have been exposed via the<br />

document object since the earliest days.<br />

In more modern object models (IE4+ and W3C DOM), the<br />

BODY element is its own object. The document object<br />

strengthens its role as a “super-container” of all the HTML element<br />

objects in the page. Thus, the BODY element object is a<br />

child element of the root document object (see Chapter 14 of<br />

the <strong>JavaScript</strong> <strong>Bible</strong> for more details). But now that the BODY<br />

element object can expose its own attributes as properties,<br />

the document object no longer needs to play that role, except<br />

for the sake of backward compatibility with scripts written for<br />

older browsers. Instead, the document object assumes an<br />

even greater role, especially in the W3C DOM, by providing<br />

critical properties and methods of a global nature for the<br />

entire document.<br />

4<br />

C H A P T E R<br />

✦ ✦ ✦ ✦<br />

In This Chapter<br />

Accessing arrays of<br />

objects contained by<br />

the document object<br />

Writing new<br />

document content to<br />

a window or frame<br />

Managing BODY<br />

element scrolling in IE<br />

✦ ✦ ✦ ✦

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!