Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1124 Is there a way of ensuring that specific image files are loaded first?

You are here: irt.org | FAQ | JavaScript | Image | Q1124 [ previous next ]

Try:

<html>
<head>

<script language="JavaScript"><!--
/* Script to load images in order (c) 1999 Michel Plungjan jav@scripting.demon.nl */

theImage = new Array('im1.gif','im2.gif','im3.gif')

Loaded = false;

function loadNext(imageName, image2Load) {
    if (!document.images || !Loaded) return; // images not supported
    document.images[imageName].src = theImage[image2Load];
}
//--></script>

</head>

<body onLoad="Loaded=true; loadNext('image0',0);">
<img src="blank.gif" name="image0" onLoad="loadNext('image1',1);">
<img src="blank.gif" name="image1" onLoad="loadNext('image2',2);">
<img src="blank.gif" name="image2">
</body>

</html>

©2018 Martin Webb