/    Sign up×
Community /Pin to ProfileBookmark

Preloading images that are used as background in css

(I am sorry If this has already been addressed but I just thought my case was a bit rare)

So this is confusing me a bit.

I have a page where there are 4 images that are loaded as a div background via css file.

When I try to use javascript to preload them it just does not look like its pre loading them.

I tried doing the following but the images don’t pre loaded. They appear one after another.

[code]
<SCRIPT language=”JavaScript”>
<!–
pic1= new Image(100,25);
pic1.src=”http://someplace.com/image1.gif”;
//–>
</SCRIPT>

[/code]

Any tips gurus?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@3NexMay 01.2010 — What does [COLOR="Red"](100,25)[/COLOR] mean and where did you see that? I have never seen the Image constructor take any arguments and [COLOR="Red"]new Image()[/COLOR] has always worked fine for me..
Copy linkTweet thisAlerts:
@Door7authorMay 01.2010 — Here:

http://www.pageresource.com/jscript/jpreload.htm

But I don't use that argument because I don't want my images to be loaded with specific height and width.

(height,width) i think.

Anyway, does anyone have any answers to my initial question?
Copy linkTweet thisAlerts:
@tirnaMay 01.2010 — I've got some ideas but unless you post all your code (js and html where the image is called) instead of just 2 lines of it then I am only guessing and am not going to waste time posting something which may or may not apply.
Copy linkTweet thisAlerts:
@3NexMay 02.2010 — Please, just try using new Image() with no arguments and then tell me if that solved it.

If that didn't resolve it, then upload everything to a server and post the link.
×

Success!

Help @Door7 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.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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