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.

Note<br />

Chapter 4 ✦ The Document and Body Objects (Chapter 18)<br />

<br />

<br />

<br />

<br />

drawPage(“default”)<br />

<br />

<br />

<br />

To satisfy the curiosity of those who want to change the color of a loaded document<br />

on the fly, the preceding example includes a pair of buttons that set the color<br />

properties of the current document. If you’re running browsers and versions capable<br />

of this power (see Table 18-1), everything will look fine; but in other platforms<br />

or earlier versions, you may lose the buttons and other document content behind<br />

the color. You can still click and activate these items, but the color obscures them.<br />

Unless you know for sure that users of your Web page use only browsers and<br />

clients empowered for background color changes, do not change colors by setting<br />

properties of an existing document.<br />

anchors<br />

If you are using Internet Explorer 3 for the Macintosh, you will experience some<br />

difficulties with Listing 18-1. The script in the main document loses its connection<br />

with the subwindow; it does not redraw the second window with other colors.<br />

You can, however, change the colors in the main document. The significant flicker<br />

you may experience is related to the way the Mac version redraws content after<br />

changing colors.<br />

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

Compatibility ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

In Listing 18-2, I append an extra script to Listing 17-1 (in Chapter 3 of this<br />

book) to demonstrate how to extract the number of anchors in the document.<br />

The document dynamically writes the number of anchors found in the document.<br />

You will not likely ever need to reveal such information to users of your page, and<br />

the document.anchors property is not one that you will call frequently. The object<br />

model defines it automatically as a document property while defining actual anchor<br />

objects.<br />

227<br />

document.anchors

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

Saved successfully!

Ooh no, something went wrong!