/    Sign up×
Community /Pin to ProfileBookmark

Simple Image Preloader? …but it’s not working!!

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]);
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliOct 14.2003 — 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.
Copy linkTweet thisAlerts:
@justin001authorOct 14.2003 — Thanks v much for the help! Much appreciated!

Justin
Copy linkTweet thisAlerts:
@Khalid_AliOct 14.2003 — No problem..:-)
×

Success!

Help @justin001 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...