Click to See Complete Forum and Search --> : run animated gif first
tak237
04-21-2003, 01:34 PM
I have an animated gif on my web page which lasts for something like 5 seconds. The page also contains a few ordinary images.
At the moment all of the images load at the same time (ie the animated gif and the images). Is there a way to make the animated gif load (and run) first and then load the rest of the images when it's finished?
Thanks.
Hm.....
<html><head>
<script>
var imgs;
function doImgs(){
document.images['myGif'].src="my_gif.gif"; //set the first image's source to my_gif.gif; change this to the location of your gif file
imgs = setTimeout("otherImgs()", 5000); //after 5 seconds, execute function otherImgs().
}
function otherImgs(){
document.images['others1'].src="others1.gif";
document.images['others2'].src="others2.gif";
clearTimeout(imgs);
}
</script></head>
<body onload="doImgs()">
<img name="myGif"><br>
<img name="others1"><br>
<img name="others2"><br>
[etc..]
</body></html>
tak237
04-21-2003, 02:07 PM
Jona,
Thanks very much. The code works fine but the problem is that I get this annoying 'Not available' image until the rest of the images load.
Is there a way to avoid this?
AdamGundry
04-21-2003, 02:10 PM
How about this?
<html><head>
<script>
var imgs;
function doImgs(){
document.images['myGif'].src="my_gif.gif"; //set the first image's source to my_gif.gif; change this to the location of your gif file
imgs = setTimeout("otherImgs()", 5000); //after 5 seconds, execute function otherImgs().
}
function otherImgs(){
document.images['others1'].src="others1.gif";
document.images['others2'].src="others2.gif";
document.images['others1'].style.visibility="visible";
document.images['others2'].style.visibility="visible";
clearTimeout(imgs);
}
</script></head>
<body onload="doImgs()">
<img name="myGif"><br>
<img name="others1" style="visibility: hidden"><br>
<img name="others2" style="visibility: hidden"><br>
[etc..]
</body></html>
Adam
tak237
04-21-2003, 02:15 PM
Yes! That did it.
Thank you both very much!