1. Home
  2. Computing & Technology
  3. JavaScript

Rollover Gallery

3. Add to Your Page

clr gif
Join the Discussion

Questions? Comments?

More of this Feature

Introductiont Obtain the Script

All that remains to be done (assuming you added the image rollover processing before amending it to add the captions) is to amend your web page to add the caption field and change the onmouseover events to call the rollover function so that both the image and caption get updated.

Here is the code that you need to add within the body of the page where you want the caption to appear:

<p align="center" id="caption">Picture One</p>

The content of the paragraph should be the same as the first entry in the cap array as that is the caption for the image that displays when the page first loads.

The final step is to update the mouseovers. To do this you simply locate all of the occurrences of the following code (the numbers as shown in bold will vary):

onmouseover="document.rollimg.src=image1.src;"

You now replace each of those pieces of code with the following instead (you just need to retain the number from the original code):

onmouseover="rollover(1)"
Sample Page | Obtain the Script | Add to Your Page

Explore JavaScript

More from About.com

  1. Home
  2. Computing & Technology
  3. JavaScript

©2008 About.com, a part of The New York Times Company.

All rights reserved.