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.

all<br />

Chapter 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with the<br />

all collection. Enter the following statements one at a time into the lower text box,<br />

and review the results in the textarea for each.<br />

document.all<br />

myTable.all<br />

myP.all<br />

If you encounter a numbered element within a collection, you can explore that<br />

element to see which tag is associated with it. For example, if one of the results for<br />

the document.all collection says document.all.8=[object], enter the following<br />

statement into the topmost text box:<br />

document.all[8].tagName<br />

attributes<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to examine the values of<br />

the attributes array for some of the elements in that document. Enter each of the<br />

following expressions into the lower text field, and see the array contents in the<br />

Results textarea for each:<br />

document.body.attributes<br />

document.getElementById(“myP”).attributes<br />

document.getElementById(“myTable”).attributes<br />

If you have both NN6 and IE5, compare the results you get for each of these<br />

expressions. To view the properties of a single attribute in IE5/Windows, enter the<br />

following statement into the bottom text field:<br />

document.getElementById(“myP”).attributes[“class”]<br />

For NN6 and IE5/Mac, use the W3C DOM syntax:<br />

document.getElementById(“myP”).attributes.getNamedItem(“class”)<br />

5<br />

elementObject.attributes

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

Saved successfully!

Ooh no, something went wrong!