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 13 ✦ Event Objects (Chapter 29)<br />

Listing 29-15: Using the toElement and fromElement<br />

Properties<br />

<br />

<br />

fromElement and toElement Properties<br />

<br />

.direction {background-color:#00FFFF; width:100; height:50; text-align:center}<br />

#main {background-color:#FF6666; text-align:center}<br />

<br />

<br />

function showArrival() {<br />

var direction = (event.fromElement.innerText) ? event.fromElement.innerText<br />

:<br />

“parts unknown”<br />

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

}<br />

function showDeparture() {<br />

var direction = (event.toElement.innerText) ? event.toElement.innerText :<br />

“parts unknown”<br />

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

}<br />

<br />

<br />

<br />

fromElement and toElement 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 />

417<br />

(IE) event.fromElement

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

Saved successfully!

Ooh no, something went wrong!