[thelist] Image preload problem NN6

Tyme nopun at bellsouth.net
Sun Jul 29 18:19:00 CDT 2001


----- Original Message -----
From: Peter-Paul Koch <gassinaumasis at hotmail.com>
To: <thelist at lists.evolt.org>
Sent: Friday, July 27, 2001 12:51 PM
Subject: Re: [thelist] Image preload problem NN6


> >Reference: http://www.huntacpa.com/
> >
> >Any idea why this .js script does not appear to be preloading the images
> >for
> >Netscape 6?  Works fine for IE4 and IE5.01.  (File is called in
> ><head></head>.)
> >
> >images = new Array;
>
> I think it's because you call your array 'images'. The array
> document.images[] already exists: it's the array with all the images in
the
> page. When you declare your own array, the browser becomes terribly
confused
> and tries to add a .src property to the images[] you have declared. Of
> course, nothing happens.
>
> Solution: change the name of the array.

TYME} Thanks for the suggestion. That did seem to resolve the preload
problem.  However, now the images are changing too frequently for NN6.
Should just change on mouseover.  Not mouseover and mouseout.  View in IE4
or IE5.01 to see how it should work.

var rand1 = 0;
var useRand = 0;

arrPhotos = new Array;
arrPhotos[1] = new Image(190,290);
arrPhotos[1].src = "photo1.jpg";
arrPhotos[2] = new Image(190,290);
arrPhotos[2].src = "photo2.jpg";
arrPhotos[3] = new Image(190,290);
arrPhotos[3].src = "photo3.jpg";
arrPhotos[4] = new Image(190,290);
arrPhotos[4].src = "photo4.jpg";
arrPhotos[5] = new Image(190,290);
arrPhotos[5].src = "photo5.jpg";


function swapPic() {
var imgnum = arrPhotos.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg.src = arrPhotos[useRand].src;
}






More information about the thelist mailing list