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 />

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

tags() method. Enter the following statements one at a time into the upper text<br />

box and study the results:<br />

document.all.tags(“DIV”)<br />

document.all.tags(“DIV”).length<br />

myTable.all.tags(“TD”).length<br />

Because the tags() method returns an array of objects, you can use one of<br />

those returned values as a valid element reference:<br />

document.all.tags(“FORM”)[1].elements.tags(“INPUT”).length<br />

urns(“behaviorURN”)<br />

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

Compatibility ✓ ✓<br />

Example<br />

In case the urns() method is reconnected in the future, you can add a button<br />

and function to Listing 15-19b that reveals whether the makeHot.htc behavior is<br />

attached to the myP element. Such a function looks like this:<br />

function behaviorAttached() {<br />

if (document.all.urns(“makeHot”)) {<br />

alert(“There is at least one element set to \’makeHot\’.”)<br />

}<br />

}<br />

Event handlers<br />

onActivate<br />

onBeforeDeactivate<br />

onDeactivate<br />

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

Compatibility ✓<br />

Example<br />

You can modify Listing 15-34 later in this chapter by substituting onActivate for<br />

onFocus and onDeactivate for onBlur.<br />

95<br />

elementObject.onActivate

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

Saved successfully!

Ooh no, something went wrong!