Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Image | Q1124 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.