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.

120<br />

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

onMouseOut<br />

onMouseOver<br />

elementObject.onMouseOut<br />

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

Compatibility ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

Listing 15-44 uses the U.S. Pledge of Allegiance with four links to demonstrate<br />

how to use the onMouseOver and onMouseOut event handlers. Notice that for each<br />

link, the handler runs a general-purpose function that sets the window’s status message.<br />

The function returns a true value, which the event handler call evaluates to<br />

replicate the required return true statement needed for setting the status bar. In<br />

one status message, I supply a URL in parentheses to let you evaluate how helpful<br />

you think it is for users.<br />

Listing 15-44: Using onMouseOver and onMouseOut Event<br />

Handlers<br />

<br />

<br />

onMouseOver and onMouseOut Event Handlers<br />

<br />

function setStatus(msg) {<br />

status = msg<br />

return true<br />

}<br />

// destination of all link HREFs<br />

function emulate() {<br />

alert(“Not going there in this demo.”)<br />

}<br />

<br />

<br />

<br />

onMouseOver and onMouseOut Event Handlers<br />

<br />

<br />

Pledge of Allegiance<br />

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

Saved successfully!

Ooh no, something went wrong!