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.

onLoseCapture<br />

Chapter 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

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

Compatibility ✓ ✓<br />

Example<br />

See Listing 15-30 earlier in this chapter for an example of how to use<br />

onLoseCapture with an event-capturing scenario for displaying a context menu.<br />

The onLoseCapture event handler hides the context menu when the user performs<br />

any action that causes the menu to lose mouse capture.<br />

onMouseDown<br />

onMouseUp<br />

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

Compatibility ✓ ✓ ✓ ✓ ✓<br />

Example<br />

To demonstrate a likely scenario of changing button images in response to<br />

rolling atop an image, pressing down on it, releasing the mouse button, and rolling<br />

away from the image, Listing 15-42 presents a pair of small navigation buttons<br />

(left- and right-arrow buttons). Because the image object is not part of the document<br />

object model for NN2 or IE3 (which reports itself as Navigator version 2),<br />

the page is designed to accept all browsers. Only those browsers that support<br />

precached images and image swapping (and thus pass the test for the presence of<br />

the document.images array) can execute those statements. For a browser with an<br />

image object, images are preloaded into the browser cache as the page loads so<br />

that response to the user is instantaneous the first time the user calls upon new<br />

versions of the images.<br />

Listing 15-42: Using onMouseDown and onMouseUp Event<br />

Handlers<br />

<br />

<br />

onMouseDown and onMouseUp Event Handlers<br />

<br />

if (document.images) {<br />

var RightNormImg = new Image(16,16)<br />

var RightUpImg = new Image(16,16)<br />

Continued<br />

115<br />

elementObject.onMouseDown

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

Saved successfully!

Ooh no, something went wrong!