15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5 ✦ Body Text Objects (Chapter 19)<br />

Example<br />

See Listing 19-1 for an example of values that can be used to set the face property<br />

of a FONT element object. While you will notice visible changes to most<br />

choices on the page, the font face selections may not change from one choice to<br />

another; this all depends on the fonts that are installed on your PC.<br />

size<br />

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

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

See Listing 19-1 for an example of values that can be used to set the size property<br />

of a FONT element object. Notice that incrementing or decrementing the size<br />

property is applied only to the size assigned to the SIZE attribute of the element<br />

(or the default, if none is specified) and not the current setting adjusted by script.<br />

HR Element Object<br />

Properties<br />

align<br />

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

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

Listing 19-2 contains a page that demonstrates the changes to the five HR element<br />

object properties: align, color, noShade, size, and width. Along the way,<br />

you can see an economical use of the setAttribute() method to do the work for<br />

all of the property changes. This page loads successfully in all browsers, but the<br />

SELECT lists make changes to the text only in IE4+ and NN6+ (because they treat<br />

the element as an object).<br />

An HR element (whose ID is myHR) is displayed with the browser default settings<br />

(100% width, centered, and its “magic” color). Each list controls one of the five HR<br />

object properties, and their NAME attributes are strategically assigned the names of<br />

the properties (as you see in a moment). VALUE attributes for OPTION elements contain<br />

strings that are to be assigned to the various properties. Each SELECT element<br />

269<br />

HR.align

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

Saved successfully!

Ooh no, something went wrong!