Preloading multiple images in Javascript

<script language="JavaScript"
type="text/JavaScript">
function preloadImages(urls) {
var img = new Array();
for (var i=0; i<urls.length; i++) {
img[img.length] = new Image();
img[img.length - 1].src = urls[i];
}
}
window.onload = function() {
var img = new Array(
"active.gif", "inactive.gif", "other.gif");
preloadImages(img);
}
</script>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.