Click to See Complete Forum and Search --> : Simple Image Preloader? ...but it's not working!!


justin001
10-14-2003, 02:01 AM
Placed in the <head> of my document, the following code has absolutely no effect whatsoever...

...does anyone have any idea why? Seems alright to me..?


function imagePreLoader(pSrc)
{
var newImg=new Image()
newImg.src=pSrc;
}

function preLoadImages()
{
var imgSrcArray=['images/nav_07on.gif',
'images/nav_08on.gif',
'images/images/nav_09on.gif',
'images/nav_15on.gif',
'images/menu_products_on.gif',
'data.pertec.co.za/images/menu_news_on.gif',
'images/menu_newsletter_on.gif',
'images/menu_links_on.gif',
'nav_23_on.gif'];
for (var i=0;i<imgSrcArray.length;i++)
imagePreLoader(imgSrcArray[i]);
}

Khalid Ali
10-14-2003, 07:52 AM
of course it does not have any effect,
you need to store the images after preloading in some array to use them

the following will work
var imgArray = new Array();
function imagePreLoader(n,pSrc)
{
imgArray[n] =new Image()
imgArray[n].src=pSrc;
}

once done youcan use imgArray to retrieve preloaded images.

justin001
10-14-2003, 08:42 AM
Thanks v much for the help! Much appreciated!

Justin

Khalid Ali
10-14-2003, 08:48 AM
No problem..:-)