Random Image Display
From DMXZone -
In the sample code there are 3 images, defined in var id = 3 ; change this to
the total number of images you wish to add in the script. Then you need to put the full list of images
with one line per image in the following format ranimage[number starting with 0 then 1, etc..] = "imagename.format";
1: script language="JavaScript" type="text/javascript">
2: // This script was supplied by Dave Joosten
4: < !-- var id = 3; // Total number of images
5: var ranimage = new Array(ic); // Array to hold the filenames
6:
7: ranimage[0] = "http://www.yourwebsite.com/graphic1.jpg";
8: ranimage[1] = "http://www.yourwebsite.com/graphic2.jpg";
9: ranimage[2] = "http://www.yourwebsite.com/graphic3.jpg";
10:
11: function choseRandom(range) {
12: if (Math.random)
13: return Math.round(Math.random() * (range-1));
14: else {
15: var now = new Date();
16: return (now.getTime() / 1000) % range;
17: }
18: }
19: //
20: var choice = choseRandom(id);
21: // -->
22: < /script>
23:
24:
Posted by sachauncey at August 14, 2003 04:47 PM