Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preload with rollover problems

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am having problems with a page that is supposed to preload a number of images that are then used for a rollover. They rollover works, but the images are not being preloaded.
here is the URL of the page:

please take a look and let me know why this is happening

thanks
 
here is essentially what you have:

if (document.images) {
arImage = new Array ( a whole bunch of images )

for (i=0;i<arImage.length;i++){
arImage = new Image();
arImage.src = arImage;
}
}

your problem lies in the for loop. Lets step through what your loop is doing:
1) the current slot of the array is filled with a new Image() object, therefore ERASING the src of the image.
2)you store the current slot of the array to the src property of the same slot.

I'm not sure if that makes sense, but anyway, here is the soloution:
change your loop to this:

for (i=0;i<arImage.length;i++){
temp=arImage;
arImage=new Image();
arImage.src=temp;
}

try it and see.
temp=


theEclipse
eclipse_web@hotmail.com
robacarp.webjump.com
**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top