/    Sign up×
Community /Pin to ProfileBookmark

image swap works only once in Safari

Please take a look at this example: [url]http://www.mojamatize.com/swap/index_safari.html[/url]

After clicking the link, the text box will scroll into position and then the preload() function on line 27 is called. A new image is created (red.gif). Then the current image (blue.gif) is supposed to be replaced by that new image using the changeImage() function (on lines 18-24).

This works fine on (Mac) IE5 and on NS7 upon first activation and still works if you refresh the page..

On Safari however, the process only works upon opening a new window, not after repeated refreshes.

I’ve even checked the source of the image with javascript:alert(document[‘sp1’].src) in the address box and it tells me that the image is red.gif but blue.gif is still showing. No visible change.

Obviously it doesn’t like the code or it’s just a lazy browser. Any suggestions for helping it actually change to the red.gif?

thanks,

Brad

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@dragleSep 09.2003 — Possibly some type of reflow problem? Try adding a small timeout before your image swap, i.e.,
<i>
</i>setTimeout('changeImage("sp1","red")',100);

HTH,
Copy linkTweet thisAlerts:
@transmatauthorSep 09.2003 — that worked.

thanks Dan.
Copy linkTweet thisAlerts:
@dragleSep 09.2003 — You're welcome!
×

Success!

Help @transmat 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.20,
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,
)...