JAVASCRIPT :: Image-Link Rotator
2000
This "Image-Link Rotator" JavaScript creates an "animated gif"-like effect by rotating several image files. Each image in the animation can link to its own different URL. Older browsers or those with JavaScript disabled will see only the first image and link and no animation.
Example of the JavaScript code used:
<SCRIPT LANGUAGE="javascript">
<!--
// note: the 2nd image ("two") will be the first to appear in the animation
// all images must be the same dimensions
// works in NS 3, IE/NS 4+
// other browsers or javascript disabled will see only the original image and link and no animation
var has_loaded = 0;
if (document.images) {
one=new Image
one.src="images/logo1.gif"
two=new Image
two.src="images/logo2.gif"
three=new Image
three.src="images/logo3.gif"
has_loaded = 1;
}
go_URL = new Array();
go_URL[0]="http://www.cnn.com/";
go_URL[1]="http://www.yahoo.com/";
go_URL[2]="http://www.excite.com/";
imgID = new Array();
imgID[0]=one.src;
imgID[1]=two.src;
imgID[2]=three.src;
var pause = 3000 // pause how long in milliseconds (1000 = 1 sec)
var a = 0;
var b = (go_URL.length - 1);
function rotate(imgN) {
if (has_loaded == 1) {
if (a == b) {
a = 0;
}
else {
a++;
}
document.images[imgN].src = imgID[a];
setTimeout('rotate("rotate_pic")',pause);
} // end of if has_loaded
if (window.status != '') { window.status = go_URL[a]; return true; }
} // end of function rotate
function goto_url() {
if (document.images) {
document.location=(go_URL[a]);
}
else {
return false;
}
}
//-->
</SCRIPT>