Random Image Script

Here's the example - keep pressing F5 to reload the page, and check out the way the images change.

Here's the code:

Copy this into the <head> portion of your HTML

And this into the <body> section, wherever you want the random images to go

Look at the code in the top window - where we've got "image1.gif" is where you put your image names. You can change the number of images this supports by changing the
"number = Math.floor(Math.random() *3) line - change the "3" to the number of images you want to use, and add more "if (number==...) lines, incrementing the number in each line.

You can use.GIF files as well as .JPG files - as long as they're in the same directory as the page they're on. If you want to be really clever, you can add the full route to the files in the statments.

It's a simple as that!

Back whence you came

counter