1. Computing
Send to a Friend via Email

Multiple Galleries with Captions

1. Introduction and Example

Adding a photo or picture gallery or more than one is made simple with this unobtrusive JavaScript.

You just need to supply five values when creating a gallery object in JavaScript for it to set up everything necessary to display that gallery. The first parameter is the id of the div in the web page where you want the gallery to display, the second and third are the width and height of the images that you are displaying,the fourth is an array that contains the information for the images in your gallery, and the fifth is the time in 1/1000ths of a second that you want each picture in that gallery to display for before the script automatically displays the next picture.

The array is an array of objects rather than an array of images because this script not only displays the images but it displays a caption under each image as well. We'll look at a couple of different ways you can define the array when we look at how to add the script to your page.

Note that this script preloads the next image while the prior image is displaying so as to minimise the delay in displaying the page at the start while ensuring that each image is available immediately when needed. This will only cause a problem if you try to cycle through the images more quickly than the browser can download them all.

If you want to add image galleries like this to your site then the first thing you need to do is to obtain the script.

©2014 About.com. All rights reserved.