Help me, I’ve been trying to successfully preload some images using javascript … but had no luck so far… I am using :
[code=php]
var imgs = new Array(“image1.jpg”, “image2.jpg”, …);
function preloadEm() {
for (i=0; i<imgs.length; i++) new Image().src=imgs[i];
}
——
<body onLoad=”preloadEm()”>
Do I like have to use another array to hold the images? Like :
[code=php]
var imgs = new Array(“image2.jpg”, “image2.jpg”, …);
var imgs2 = new Array();
function preloadEm() {
for (i=0; i<imgs.length; i++) {
imgs2[i] = new Image();
imgs2[i].src = imgs[i];
}
}
Can anyone help me? Which is the right way to preload images with javascript?