C
cjl
Hey all:
Just getting my feet wet with javascript. The following script works
fine in Firefox, but won't run in IE. In fact, I've included this
script as an external file in the <head> of my html file, and the
remainder of the page doesn't load at all in IE. If I remove the
<script>, the page loads in IE.
var images = new Array();
var firstImage = 2;
var lastImage = 27;
var timeout_state = null;
var counter = 0;
var running = 0;
for (counter=firstImage;counter<=lastImage;counter++)
{
images[counter] = new Image();
images[counter].src = counter + ".jpg";
}
counter = firstImage;
function switchImage()
{
if(running == 0)
{
running = 1;
animate();
}
else
{
running = 0;
clearTimeout(timeout_state);
timeout_state = null;
}
}
function animate(element)
{
if (counter >= lastImage) {counter = firstImage;}
document.getElementById('right').src = images[counter].src;
counter++;
timeout_state = setTimeout("animate()", 50);
}
Any help?
-CJL
Just getting my feet wet with javascript. The following script works
fine in Firefox, but won't run in IE. In fact, I've included this
script as an external file in the <head> of my html file, and the
remainder of the page doesn't load at all in IE. If I remove the
<script>, the page loads in IE.
var images = new Array();
var firstImage = 2;
var lastImage = 27;
var timeout_state = null;
var counter = 0;
var running = 0;
for (counter=firstImage;counter<=lastImage;counter++)
{
images[counter] = new Image();
images[counter].src = counter + ".jpg";
}
counter = firstImage;
function switchImage()
{
if(running == 0)
{
running = 1;
animate();
}
else
{
running = 0;
clearTimeout(timeout_state);
timeout_state = null;
}
}
function animate(element)
{
if (counter >= lastImage) {counter = firstImage;}
document.getElementById('right').src = images[counter].src;
counter++;
timeout_state = setTimeout("animate()", 50);
}
Any help?
-CJL