Random Picture and Random Page Scripts

Two scripts that can be used to add a little spontaneity to your site are the Random Picture script, which displays an inline graphic randomly chosen from a specified directory of picture graphics, and the Random Page script, which makes a link to a randomly chosen page in a specified directory of pages.

Random Picture

An example of the use of the Random Picture script may be seen on the Lehigh main web page, http://www.lehigh.edu. Each time the user loads that page anew, the picture in the right-hand column changes to a different randomly chosen photograph.

How is it done?

Limitations

The random picture script will display a random picture in that image spot every time the page is loaded. If there are only a few pictures, the same picture is more likely to appear repeatedly. If you set width and height tags, all the images will be displayed with those size attributes, and if the graphic is a different size, it will be stretched or shrunk to match that size anyway. Only one caption can be set for these images; you cannot set a different caption/alt tag for different images.


Random Page Linking Script

This script, when used in a hypertext link as the URL, will link to a random page in a given directory. When the page on which the link appears is loaded, a page is chosen from the directory specified and the link is pointed to that page. Each time on which the link appears is loaded, a new URL is put in place in the link. (Going to the page linked to, and reloading it, will produce no change.

How it's done


Last modified, December 30, 1997, by JAH.