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">
-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">