How to use JavaScript rollover images
"Event handlers"
are JavaScript code that are not added inside the <script> tags, but rather,
inside the html tags. They execute JavaScript when something happens, such
as pressing a button, moving your mouse over a link, submitting a form, etc.
The most common use for these event handlers are rollover images.
Rollover images are images that change when the mouse is over them. Rollover
images are really two images: one image when the mouse is over, and another
when it is not. Javascript swaps between them when the mouse moves over (onMouseOver) and when it leaves being over
(onMouseOut). The hover buttons below uses the
following code in the BODY section of the Web page:
<a href="home.htm" onmouseover="document.myimage1.src='home2.gif'"
onmouseout="document.myimage1.src='home1.gif'">
<img name=myimage1 src=home1.gif border="0" width="101" height="21"></a>
<a href="contact.htm" onmouseover="document.myimage2.src='contact2.gif'"
onmouseout="document.myimage2.src='contact1.gif'">
<img name=myimage2 src=contact1.gif border="0" width="101"
height="21"></a>
<a href="links.htm" onmouseover="document.myimage3.src='links2.gif'"
onmouseout="document.myimage3.src='links1.gif'">
<img name=myimage3 src=links1.gif border="0" width="101"
height="21"></a>
Move the mouse over the buttons
|