Click to See Complete Forum and Search --> : Rotate Images


vickiwatson
09-26-2003, 10:37 PM
I am using the following code (inside the head section) to try to rotate the display of 3 jpg files. From my hard drive the code works fine when viewed with Netscape 7.0 and IE 6.0, but from the internet the code works in Netscape, but not IE. Using IE the first image is displayed only. The status bar continually cycles through messages indicating that it is downloading the 3 images, but the image displayed never changes. I am fairly new to JavaScript. Can anyone tell me what I am doing wrong here? I've tried it with and without the clearTimer() call with the same results. I don't know if that call is necessary.

-Vicki Watson



<script language="JavaScript" type="text/javascript">
var currentpic = 1;
var numpics = 3;
var displaytime = 5000;
var timer;

if (document.images) {
var pic1 = new Image();
pic1.src = "images/horsepictures/horseparade-1.jpg";
var pic2 = new Image();
pic2.src = "images/horsepictures/horseparade-2.jpg";
var pic3 = new Image();
pic3.src = "images/horsepictures/horseparade-3.jpg";
}

function rotateparadepics() {
if (document.images) {
if (currentpic > numpics) {
currentpic = 1;
}
document.paradepictures.src = eval("pic"+currentpic+".src");
clearTimeout(timer);
timer = setTimeout("rotateparadepics()",displaytime);
currentpic++;
}
}
</script>


<body onload="rotateparadepics();" stylesrc="index.html">

<img border="0" name="paradepictures" src="images/horsepictures/horseparade-1.jpg" width="300" height="300">

Khalid Ali
09-26-2003, 11:35 PM
hunmm try this...

document.paradepictures.src = (eval("pic"+currentpic)).src;

vickiwatson
10-01-2003, 11:05 AM
I tried the suggested change, but it didn't seem to make any difference. The page is online at www.vickiwatson.com/parade.html if you want to see what it is doing.

Cerralin
10-02-2003, 10:06 AM
I have just looked at your page using Crazy Browser and I can see all 3 pictures being rotated :)

Not sure if thats any help for you Vicki?