An image gallery: Random starting image

  1. Random image
  2. An image gallery
  3. Prepare a slide show

Finally, let’s have it choose a random image every time a visitor visits the page. Add this to the end of gallery.js:

window.onload=randomImage;

This is just like the “document.onclick” we used in the “Intercepting Clicks” example. In this case, however, we’re telling the window that, when it is done loading, to call the randomImage function.

  1. Random image
  2. An image gallery
  3. Prepare a slide show