/    Sign up×
Community /Pin to ProfileBookmark

Javascript Image preload problem

I’m currently working on increasing the loading speed of a customers website. I know that using an image preload doesn’t make the site faster, but I would like to use one so nobody sees his site naked.

Here’s what I got:

[CODE]
<!–javascript image pre-load–>
<SCRIPT LANGUAGE=”JavaScript”>
<!– hide from non JavaScript Browsers

function preloader()

{
Image1= new Image();
Image1.src = “images/logo.png”;

Image2 = new Image();
Image2.src = “images/index/security-guard-computer.jpg”;

Image3 = new Image();
Image3.src = “images/index/padv-conference-banner.jpg”;

Image4 = new Image();
Image4.src = “images/index/security-guards.png”;

Image5 = new Image();
Image5.src = “images/contract_security_services.png”;

Image6 = new Image();
Image6.src = “images/private_security_services.png”;

Image7 = new Image();
Image7.src = “images/corporate_commercial_security.png”;
}

// End Hiding –>

<!–end preload–>
</SCRIPT>
</head>
<body onLoad=”javascript:preloader()”>[/CODE]

There must be a mistake I’m making. I notice when I clear my browser cache and try loading the page that the images still appear visible while loading.
I’ve done a lot of digging in the forums and through the internet and decided I just needed to ask.

Any thoughts?

You can visit the page at [URL=”http://www.taurusprotection.com”]http://www.taurusprotection.com[/URL]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 22.2010 — No function, no onload necessary:&lt;script type="text/javascript"&gt;
Image1= new Image();
Image1.src = "images/logo.png";

Image2 = new Image();
Image2.src = "images/index/security-guard-computer.jpg";

Image3 = new Image();
Image3.src = "images/index/padv-conference-banner.jpg";

Image4 = new Image();
Image4.src = "images/index/security-guards.png";

Image5 = new Image();
Image5.src = "images/contract_security_services.png";

Image6 = new Image();
Image6.src = "images/private_security_services.png";

Image7 = new Image();
Image7.src = "images/corporate_commercial_security.png";
&lt;/script&gt;
Copy linkTweet thisAlerts:
@ZackM90authorApr 23.2010 — Thanks fang, I believe that may have solved the problem.
×

Success!

Help @ZackM90 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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