/    Sign up×
Community /Pin to ProfileBookmark

Hello. This is my first post here. It looks like a nice enough forum!!

I have a sleight problem with preloading images. I create a new image object:

[COLOR=blue]var image1 = new Image();[/COLOR]

Then I assign an image to that var:

[COLOR=blue]image1.src = theImage.jpg;[/COLOR]

I then give a name to an <img> tag and place it into an anchor. Of course whilst testing on my local machine, the mouseover works as expected, nice and crisp. When I test online, it’s obvious that the image is not being assigned to the variable… I have tried placing the code in and out of the head tag, with the same results.
I’m using IE on XP pro. Thanks in advance for any advice.

I’m familiar with PHP, C, C++ and a little bit of ASM if anyone needs some help in those areas. Cheers, Nick.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliOct 25.2003 — since you have shown us partial code,I can only guess that your image is not accessible when you are trying to point to it on line

1. wrong directory/folder

2. image name has speces or invalid chars init.

Assuming there is nothing wrong with your other code
Copy linkTweet thisAlerts:
@nickeaxauthorOct 25.2003 — Khalid, thanks for the quick reply. The none mouseover image and the mouseover image work fine, but not instantly. If I hover over the button that's meant to trigger the event, eventually the image loads. I can achieve the same effect using the hide attribute in CSS, but it's quite messy with all the positioning and stuff...
×

Success!

Help @nickeax 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.25,
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,
)...