Web site design - 352Part IIIDocument Objects ReferenceonmouseoutonmouseoverCompatibility:WinIE3+, MacIE3+, NN2+, Moz1+, Safari1+
352Part IIIDocument Objects ReferenceonmouseoutonmouseoverCompatibility:WinIE3+, MacIE3+, NN2+, Moz1+, Safari1+ The onmouseoverevent fires for an object whenever the cursor rolls into the rectangularspace of the object on the screen. The onmouseoutevent handler fires when you move thecursor outside the object s rectangle. These events most commonly display explanatory textabout an object in the window s status bar and effect image swapping (so-called mouserollovers). Use the onmouseoverevent handler to change the state to a highlighted version; use the onmouseoutevent handler to restore the image or status bar to its normal setting. While these two events have been in object models of scriptable browsers since the beginning, they were not available to most objects in earlier browsers. IE4+ and W3C DOM-compatiblebrowsers provide support for these events on every element that occupies space on the screen. IE5.5+ includes an additional pair of event handlers onmouseenterand onmouseleave thatduplicate the onmouseoverand onmouseoutevents but with different terminology. The oldevent handlers fire just before the new versions. The onmouseoutevent handler commonly fails to fire if the event is associated with an ele- ment that is near a frame or window edge and the user moves the cursor quickly outside ofthe current frame. ExampleListing 15-43 uses the U.S. Pledge of Allegiance with four links to demonstrate how to use theonmouseoverand onmouseoutevent handlers. Notice that for each link, the handler runs ageneral-purpose function that sets the window s status message. The function returns a truevalue, which the event handler call evaluates to replicate the required returntruestate- ment needed for setting the status bar. In one status message, I supply a URL in parenthesesto let you evaluate how helpful you think it is for users. Listing 15-43: Using onmouseover and onmouseout Event Handlers
onmouseover and onmouseout Event Handlers
Pledge of Allegiance
I pledge