views:

264

answers:

3

Take the following HTML:

<img src="/any-animated-gif.gf" alt="" />
<br /><br />
<a href="#" onclick="document.location='/anything-that-takes-a-few-seconds-to-load.html';return false;">Click Here</a>

When I click the link the icon stops.

A: 

Yes, when the browser is going to a new page, all execution of the existing page stops by design. If you wish the current page to continue to function you need to use AJAX techniques.

Diodeus
A: 

Why are you using Documnet.Location instead of href?

You cannot change the browser's behavior. Once its loading a different page the current page will always stop.

Jason Coyne
Clearly there's more logic than what is in that simple example...
Andrew G. Johnson
+2  A: 

http://elliottback.com/wp/animated-gif-stops-javascript-click/

According to that link, reassigning the src of the image tag after you have made the redirect with javascript will keep the image animated. Not sure how this acts in firefox.

shady
Doesn't work in FF.
Andrew G. Johnson
You will need to use a main DIV and then set the innerHTML value of that DIV with a AJAX request, or contain the image in an iframe. It says that at the bottom of the article if you notice. Good luck!
shady
+1 thanks this worked for me.
bendewey