|
|
Want to randomly display images and hyperlinks from a list? No problem, you can do it with a simple script like the one shown here. The script shown below randomly loads an image from the list you input each time a page is loaded into a browser. This example works with three images. You can add as many as you like. You can even add the same image twice to double its weighting. For example, if you have two images and would like one to be shown twice as much as the other one, simply add the preferred image twice (to total three images in all).
Here�s the Script Code. All you have to do is replace the variable "imagenumber" with the correct amount of images you�re using. Be sure to label each image with its corresponding number in the images array. Then do the same for the corresponding links. You can also control your image attributes in the display portion of this script, which begins with "document.write" � That�s it. Load in your info, refresh the page and watch what happens!
Here's What the Sample Code Looks Like:
|