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 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

Example<br />

Values for the lang property consist of strings containing valid ISO language<br />

codes. Such codes have, at the minimum, a primary language code (for example,<br />

“fr” for French) plus an optional region specifier (for example, “fr-ch” for Swiss<br />

French). The code to assign a Swiss German value to an element looks like the<br />

following:<br />

document.all.specialSpan.lang = “de-ch”<br />

language<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

Although it is unlikely that you will modify this property, the following example<br />

shows you how to do it for a table cell object:<br />

document.all.cellA3.language = “vbs”<br />

lastChild<br />

See firstchild.<br />

length<br />

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

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

Example<br />

You can try the following sequence of statements in the top text box of The<br />

Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to see how the length property<br />

returns values (and sets them for some objects). Note that some statements work<br />

in only some browser versions.<br />

(All browsers) document.forms.length<br />

(All browsers) document.forms[0].elements.length<br />

(NN3+, IE4+) document.images.length<br />

(NN4+) document.layers.length<br />

(IE4+) document.all.length<br />

(IE5+, NN6) document.getElementById(“myTable”).childNodes.length<br />

29<br />

elementObject.length

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

Saved successfully!

Ooh no, something went wrong!