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.

224<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

It is clear, of course, that the BODY element has an important role to play. Both<br />

the IE4+ and W3C DOMs expose the document.body property, which returns a reference<br />

to the BODY element of the current document. The IE4+ DOM, however,<br />

bestows even more importance to the BODY element, by forcing it to be the frame<br />

of reference for how much a document’s content scrolls inside a window or frame.<br />

All other DOMs put that control into the hands of the window (that is, scrolling the<br />

window rather than the BODY element inside the window).<br />

<strong>Examples</strong> Highlights<br />

✦ Observe in Listing 18-1 how (backward-compatible) document object properties<br />

for various colors (alinkColor and the like) impact the look of the page.<br />

It may be even more important to experience the lack of dynamic control that<br />

these properties provide in a variety of browsers.<br />

✦ See how IE4+/Windows exposes date information about the document in<br />

Listing 18-4.<br />

✦ Listings 18-11 and 18-12 provide a workshop to let you test how well your target<br />

browsers support the document.referrer property. You may need to put<br />

them on your server for the real test. Unfortunately, IE/Windows doesn’t<br />

always provide the desired information.<br />

✦ If you script for W3C-DOM compatibility, be sure to grasp the<br />

document.getElementById() and document.getElementsByName() methods<br />

with the help of the example steps provided.<br />

✦ The document.write() method is one of the most important ones in the<br />

vocabulary. Listings 18-16 through 18-18 demonstrate its power.<br />

✦ See examples for document.body.scrollLeft and<br />

document.body.doScroll() to control document scrolling in IE, and the<br />

onScroll event handler example (Listing 18-21) to see how to keep a page<br />

scrolled at a fixed position.<br />

Document Object<br />

Properties<br />

activeElement<br />

document.activeElement<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓

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

Saved successfully!

Ooh no, something went wrong!