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.

430<br />

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

Listing 29-21 (continued)<br />

var direction = (evt.relatedTarget.firstChild) ?<br />

evt.relatedTarget.firstChild.nodeValue : “parts unknown”<br />

status = “Arrived from: “ + direction<br />

}<br />

}<br />

}<br />

function showDeparture(evt) {<br />

if (evt.target.nodeType == 1) {<br />

if (evt.relatedTarget != evt.target.firstChild) {<br />

var direction = (evt.relatedTarget.firstChild) ?<br />

evt.relatedTarget.firstChild.nodeValue : “parts unknown”<br />

status = “Departed to: “ + direction<br />

}<br />

}<br />

}<br />

<br />

<br />

<br />

relatedTarget Properties<br />

<br />

Roll the mouse to the center box and look for arrival information<br />

in the status bar. Roll the mouse away from the center box and look for<br />

departure information in the status bar.<br />

<br />

North<br />

West<br />

Roll<br />

East<br />

South<br />

<br />

<br />

<br />

target<br />

(NN6) eventObject.target<br />

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

Compatibility ✓<br />

Example<br />

As a simplified demonstration of the power of the target property, Listing 29-22<br />

has but two event handlers defined for the BODY element, each invoking a single

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

Saved successfully!

Ooh no, something went wrong!