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.

242<br />

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

scripts<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

You can experiment with the document.scripts array in The Evaluator<br />

(Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>). For example, you can see that only one SCRIPT<br />

element object is in The Evaluator page if you enter the following statement into the<br />

top text field:<br />

document.scripts.length<br />

If you want to view all of the properties of that lone SCRIPT element object, enter<br />

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

document.scripts[0]<br />

Among the properties are both innerText and text. If you assign an empty<br />

string to either property, the scripts are wiped out from the object model, but not<br />

from the browser. The scripts disappear because after the scripts loaded, they were<br />

cached outside of the object model. Therefore, if you enter the following statement<br />

into the top field:<br />

document.scripts[0].text = “”<br />

the script contents are gone from the object model, yet subsequent clicks of the<br />

Evaluate and List Properties buttons (which invoke functions of the SCRIPT element<br />

object) still work.<br />

selection<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

See Listings 15-30 and 15-39 in Chapter 1 of this book to see the<br />

document.selection property in action for script-controlled copying and pasting<br />

(IE/Windows only).<br />

URL<br />

document.URL<br />

See location.

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

Saved successfully!

Ooh no, something went wrong!