I have created a timer function using setTimeout. The function works perfectly in IE and Opera but doesn't work in FireFox or Netscape 6. I checked out my Javascript book where it says setTimeout is compatible with all browsers. So where am I going wrong ?
function showPics()
{
if (i > 4)
i = 0;
var index = i;
document.images("Img1").src = ImgBld[index];
index = index + 1;
if (index > 4)
index = index - 5;
document.images("Img2").src = ImgBld[index];
index = index + 1;
if (index > 4)
index = index - 5;
document.images("Img3").src = ImgBld[index];
index = index + 1;
if (index > 4)
index = index - 5;
document.images("Img4").src = ImgBld[index];
index = index + 1;
if (index > 4)
index = index - 5;
document.images("Img5").src = ImgBld[index];
index = index + 1;
if (index > 4)
index = index - 5;
i = i + 1;
setTimeout("showPics()",2000);
}
The function reads an array of image paths and displays the images in different Image tags. With the timer the images automatically change after every 2 secs. Works fine in IE & Opera, doesn't work at all in FF and NN.