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.

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

contains(elementObjectReference)<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

Using The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>), see how the contains()<br />

method responds to the object combinations in each of the following statements as<br />

you enter them into the upper text box:<br />

document.body.contains(document.all.myP)<br />

document.all.myP.contains(document.all.item(“myEM”))<br />

document.all.myEM.contains(document.all.myEM)<br />

document.all.myEM.contains(document.all.myP)<br />

Feel free to test other object combinations within this page.<br />

detachEvent()<br />

See attachEvent().<br />

dispatchEvent(eventObject)<br />

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

Compatibility ✓<br />

Example<br />

Listing 15-25 demonstrates the dispatchEvent() method as defined in the W3C<br />

DOM Level 2. The behavior is identical to that of Listing 15-26, which demonstrates<br />

the IE5.5 equivalent: fireEvent(). This example does not perform all intended<br />

actions in the first release of NN6 because the browser does not fully implement the<br />

document.createEvent() method. The example is designed to operate more completely<br />

in a future version that supports event generation.<br />

Listing 15-25: Using the dispatchEvent() Method<br />

<br />

<br />

<br />

#mySPAN {font-style:italic}<br />

<br />

<br />

// assemble a couple event object properties<br />

elementObject.dispatchEvent()

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

Saved successfully!

Ooh no, something went wrong!