A Timed Slide Show

A slide show is another good application of timed loops. Figure 9-11 shows you how to combine arrays and timing loops to create a looping slide show. Again, look the script over before diving into the explanation.

A timed slide show

Figure 9-11. A timed slide show

Line-by-Line Analysis of Figure 9-11

The first few lines set up the array containing the images we'll put in the slide show. Line ❶ creates the new array, ❷ sets the first item in the array equal to an image object, and ❸ sets the src of that image object to the first picture of the slide show. Lines ❷ and ❸ are just like the lines used to preload images before an image swap (see "Image Preloading ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.