HTML and CSS Reference
EXAMPLE 12.11 ( CONTINUED )
13 <body bgColor="black" onLoad = "preLoadImages(); slideShow()" >
Click on a Planet<br /><br />
<img src="Jupiter.bmp" name="planet_pic"
border="0" width="120" /> </a>
Global variables that will be used by the functions in this program are declared in
the head of the document.
The Array() constructor creates an array object, called planets .
The Image() constructor will preload and cache four images and assign them to
the array created in line 2.
This function starts the slideshow. It displays an array of images one at a time at
selected intervals of 1.8 seconds.
The src property of the first element of the image array is assigned an image called
Jupiter.bmp . Each array element is assigned a different image. Every 1.8 seconds
an image is replaced with a new image in the array, until all the planets have been
displayed, at which time the index value, called step , is set back to 0.
The variable, whichimage , is used to get the index value of the image that was just
clicked by the user. This value will be used in the switch statement on line 11.
As long as the value of step is less than the size of the planets array, the step value
will be incremented by 1, taking us to the next image in the array.
When the index value is greater than the size of the array, it will be reset to 0.
The function slideLink() is defined. Its purpose is to redirect the user to a page de-
scribing the planet when he or she clicks its image.