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.

266<br />

FONT.color<br />

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

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

✦ Many site visitors (this author included) frown on the application of the<br />

scrolling MARQUEE element because it tends to distract visitors, rather than<br />

convey meaningful information. But if you insist on using it, Listing 19-3<br />

demonstrates how scripts can control numerous behaviors.<br />

✦ Listing 19-4 lets you examine how the NN6 (W3C DOM) Range object treats<br />

boundary points within the node hierarchy of a document.<br />

✦ To insert a node into an arbitrary point within another, see Listing 19-5’s application<br />

of the Range.insertNode() method.<br />

✦ Walk through the steps for Range.selectNode() method to see how to set a<br />

range to encompass an entire node or its contents.<br />

✦ Run Listing 19-8 to see how NN6 (W3C DOM) provides additional facilities<br />

for manipulating text content within a node. The listing also demonstrates<br />

try-catch error handling.<br />

✦ Listing 19-10 shows the IE4+/Windows TextRange object’s way of comparing<br />

range boundaries (the IE version of Listing 19-4).<br />

✦ The TextRange object provides practical text search facilities, which are<br />

demonstrated in Listing 19-11. In the process, several TextRange properties<br />

and methods get a workout, including the use of bookmarks within a range. A<br />

simple undo buffer adds to the user friendliness of the application.<br />

FONT Element Object<br />

Properties<br />

color<br />

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

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

Listing 19-1 contains a page that demonstrates changes to the three FONT element<br />

object properties: color, face, and size. Along the way, you can see an economical<br />

use of the setAttribute() method to do the work for all of the property<br />

changes. This page loads successfully in all browsers, but the SELECT lists make<br />

changes to the text only in IE4+ and NN6+.<br />

A P element contains a nested FONT element that encompasses three words<br />

whose appearance is controlled by three select lists. Each list controls one of the

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

Saved successfully!

Ooh no, something went wrong!