![]() | ||
|
with image switching.
Below is the function for the timer.
Here is the timer that causes the delay between the switching of the images. the number '2000' means 2 seconds. It is measured in thousandths of a second.
Now here you incrementing the counter by one.
This statement is saying if the counter is greater than or equal to 6 (which is one more than the actual number of pictures) than reset the counter to 2. This actually starts the loop from the second picture. If you want it to start from the first picture, use 1 instead.
By putting the pictures in an array you can refer to them with the counter. As the counter increments, it changes the source picture.
This function ends the slideshow by clearing out the timer and putting the first picture in and resetting the counter back to 1.
All of the above goes inbetween the 'HEAD' tags.
Below is the code for precaching the images. They go after the 'BODY' tag.
![]()
You activate the slideshow with the link. Instead of linking to another HTML page, you link to your function so that they are activated when you click on the button
Click here for the code all in one piece.
Click here to see how to adapt the code to automatically trigger the slideshow when the page loads. |menu| |