Click to See Complete Forum and Search --> : image swap works only once in Safari


transmat
09-09-2003, 01:53 PM
Please take a look at this example: http://www.mojamatize.com/swap/index_safari.html

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

dragle
09-09-2003, 03:30 PM
Possibly some type of reflow problem? Try adding a small timeout before your image swap, i.e.,

setTimeout('changeImage("sp1","red")',100);

HTH,

transmat
09-09-2003, 04:52 PM
that worked.

thanks Dan.

dragle
09-09-2003, 04:58 PM
You're welcome!