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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image preloader not working

Status
Not open for further replies.

daveigh

Programmer
Oct 9, 2003
105
hi guys! It seems that my preloader is not working. What im doing is:
1) preview an item (the preloader should run on load of this page)
here is the script im using:

function preloader(imahe1,imahe2,imahe3,imahe4,imahe5)
{
var i = 0;
imageObj = new Image();
pics = new Array();
pics[0]=' + imahe1;
pics[1]=' + imahe2;
pics[2]=' + imahe3;
pics[3]=' + imahe4;
pics[4]=' + imahe5;

for(i=0; i<=3; i++)
{
alert(pics);
imageObj.src=pics;
}

}

2) see the thumbnails of the item at the bottom of the page
3) when i click the thumnail, a larger image should appear. these large image is the one ive preloaded previously. the page loads fine, but they dont show up! the image exists, i tried copy/pasting the url of the image and it shows! I have to right-click then select "Show Picture" for the image to load...any insights there?

_______________CRYOcoustic_____________
 
Code:
function preloader(imahe1,imahe2,imahe3,imahe4,imahe5){
  pics = new Array()
 
  for (x=0; x<5; x++){
    pics[x] = new Image
    pics[x].src = '[URL unfurl="true"]http://www.web.com/'[/URL] + eval('imahe' + (x+1)) 
  }
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
To make it more flexible:

Code:
function preloader()
{
var pics = new Array();
 
for (var x=0; x<arguments.length; x++)
  {
  pics[x] = new Image();
  pics[x].src = '[URL unfurl="true"]http://www.web.com/'[/URL] + arguments[x]; 
  }
}

This will allow you to send a variable number of images to the function without rewriting it, using the same format for image names.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top