Here is the source code for the above button:
<a href="#"
onMouseover="document['help_button'].src='help_button_over.gif';"
onMouseout="document['help_button'].src='help_button.gif';"
>
<img SRC="help_button.gif" name="help_button" border=0 height=24 width=130>
</a>
![]()
The next step is making the image into a link so that the Javascript events onMouseover and onMouseout can be captured. Since a link must have a href, but you don't want it to go anywhere, we direct it to "#" which is the current document. Also since you don't want the button to appear linked, you set the border to 0. The image is also named so that we can refer to it to change it.
The final step is adding the Javascript dealing with the mouse events when the mouse moves over the image and leaves the image.
onMouseover="document['help_button'].src='help_button_over.gif';"The onMouseover javascript is run when the mouse moves over the image, the onMouseout javascript is run when the mouse leaves the image.
onMouseout="document['help_button'].src='help_button.gif';"
For example...
<a href="http://www.ist.uwaterloo.ca"
![]() |
Here is the basic code for the above example.
<a href="#"There is not much different in this example, except there is a second image being changed, when the button is changed.
onMouseover="document['help_button'].src='help_button_over.gif';document['display_area'].src='Glenn.gif';"
onMouseout="document['help_button'].src='help_button.gif';document['display_area'].src='transparent.gif';"
>
<img SRC="help_button.gif" NAME="help_button" BORDER=0 height=24 width=130>
</a>
Trick: If you look at the transparent gif itself, which is hard
because it's transparent, you will see that it is only 1 pixel high and
wide. The display_area image size is the size of the image that will be
loaded into it. Normally, this would cause a problem as the smaller image
will be stretched to fill the larger area. Since the image is transparent,
you will not see that distortion.
Note: It's often better to call a Javascript routine than to
put the code directly into the <a> tag once it gets beyond changing
the image itself.