AmyMC a écrit :
Hi, I've been buried in this project, which has a lot of pre-loaded
images. The pages which have these images are frames.... and even with
my best attempts to preload them all still most do not. Some use more
than one image and the flicker is obvious.
Below is how I am loading them, and it doesn't matter if I use URL
referenced images or locally, (i.e. ./image1.gif)
<script>
pic1= new Image;
pic1.src="./image1.gif";
pic2= new Image;
pic2.src="http://www....";
that doesn't preload images in cache
they are only a kind of short-cuts to find images.
Once they have beendisplayed, this time they are in cache and it is then
possible to call them from the cache using short-cut picN.src
To post-load images :
var imgs = ['/image1.gif','http://www...'];
var n = imgs.length;
var P = new Array;
function postload() {
if(n==imgs.length) displayPicts();
else {
P[n] = new Image();
P[n].onload = postload;
P[n].src = imgs[n];
n++;
}
}
onload = postload;
function displayPicts() {
for(var i=0; i<document.images.length; i++)
if(document.images['img_'+i])
document.images['img_'+i].src = P[i];
}
</script>
Is there a reliable way to pre-load all images in frames, or *should*
this work and it's something else? :)
Where is the JS preloading images ?
Say it is in frame A and images to display are in A : OK
Say it's in main page :
from frames you would have to call them with : parent.P[x].src
--
Stephane Moriaux et son moins vieux Mac déjà dépassé
Stephane Moriaux and his less old Mac already out of date