WebworkJavaScript Random Image Rotator
Cool thing about this Random Image Rotator is that by changing one character you can convert it to a Sequential Image Rotator.
<html><head><title>Random Image Rotator</title>
<script language="JavaScript">
<!-- Begin
var interval = 1.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = sequential, 1 = random
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("01.jpg");
image_list[image_index++] = new imageItem("02.jpg");
image_list[image_index++] = new imageItem("03.jpg");
image_list[image_index++] = new imageItem("04.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
//  End -->
</script>
</head>

<body bgcolor="#ffffff" onload="rotateImage('rImage')">

<center>
<img name="rImage" src="01.jpg" width=120 height=90>
</center>

</body>
</html>

This script is from
The JavaScript Source



Javascript | Webwork Table of Contents
 
 © Jay Boersma
free stuff
GIFs 4 Us
The Web Rules
Webpix
Backgrounds 4 Us
Webpaper
Digital Sketches 1
Digital Sketches 2
Fonts
Sounds
archive
The Portals Project
Transition
Insights
Spelling
Webwork
photographs
Barcelona, Catalonia/Spain
Along the Mississippi
Rome and Florence
The Reliance Building
Providence, Rhode Island
Santa Fe, New Mexico
Charleston, South Carolina
hell
The Web
Page from
ape silverback
Primate
Ruminations
rotmp
Revenge
of the
Movie
Poster
element-j
Honda
Element
Site