shadowline
Windows << Rollovers / Image Swap >> PreLoad
Rollovers, Mouseovers, Image Swaps... It goes by many variations of names, but means the same thing. Making one image change into a different one when a mouse pointer goes over a specified area.

The first thing you will need are 2 images. One for normal view, a second for the change.

one two

The first image will be placed on the page as it normally would. The one main difference is you have to specify a name in the img tag like so...

<img src="image1.gif" name="MyImage">

This image can now be accessed by javascript as document.MyImage. Of course add in the width, height, alt, and border properties as desired too.

The next part is to create a link around that image. This will allow javascript to affect the image properties.

<a href="" onMouseOver="document.MyImage.src='image2.gif';" onMouseOut="document.MyImage.src='image1.gif';">
<img src="image1.gif" name="MyImage">

</a>

example

SRC is the SouRCe of the image file.

document.MyImage.src specifies that something is happening to the src of the object named MyImage on this document (web page). Remember... JavaScript is a step language. It goes level by level to find and use something.

OnMouseOver and OnMouseOut are self explanitory. They will do this specified coding when this event happens. For the example, They are being used to specify a new src for the named image.

This type of rollover effect is very common for navigation uses. You can create two images being close to the same. One image may have regular text on it, the other having highlighted text. Put them together in a rollover effect and you have a neat navigation happening. Placing a value in the href will complete the navigation effect.

TROUBLE SHOOTING :
If you have more than one rollover on the same web page, you MUST use a different name value for each one. Using the same name value for two or more will confuse the browser and no effect will be seen.

TIPS :
Try to use two images of the same dimensions for best results.
Windows << Rollovers / Image Swap >> PreLoad
shadow

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads
shadow
shadow