11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

onclick="theElement.innerText =<br />

document.testForm.content.value;" />><br />

<br />

<br />

<br />

<br />

<br />

<br />

document.all[]<br />

Like it or not, a great deal of script code has been written for the Internet Explorer object model<br />

discussed in the last chapter. Probably the most popular aspect of this model is<br />

document.all[]. This collection contains all the (X)HTML elements in the entire document in<br />

read order. Given that many <strong>JavaScript</strong> applications have been written to take advantage of this<br />

construct, you might wonder how it relates to the DOM. In short, it doesn‘t. <strong>The</strong> DOM doesn‘t<br />

support such a construct, but it‘s easy enough to simulate it under DOM-aware browsers. For<br />

example, under the DOM, we might use the method document.getElementsByTagName() to<br />

fetch all elements in a document. We could then set an instance property document.all equal<br />

to document .getElementsByTagName("*") if the all[] collection did not exist. <strong>The</strong> following<br />

example illustrates this idea:<br />

<br />

<br />

<br />

All Test<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!