Display Random Image Using JavaScript

This example uses JavaScript to display an image selected at random from the list you specify. Each time page loads a new selection will be made from the list.

There is no guarantee that it won't be the same image that was displayed the previous time. Of course as you increase the number of items in the list of images you specify you reduce the likelihood of repeats.

The code for this example is contained in the head of this document.

Place the following where you wish the random image to appear:

<script type="text/javascript">getRandomImage(rotator1)</script>

PHP Version

See the version that uses PHP to display an image selected at random.