Keep an Animated GIF Going After Form Submits

The following works for me in ie6,ie7,chrome but not ff3

var image = document.getElementById("loader-img");
setTimeout(function() { image.src = image.src; },50);

What can I do for more consistency?



You should do the post asynchronously, if not the UI may hang. Take a look at the jQuery Form Plugin for more information.


Try to set src to blank, then to image again. Second change may also need to be called later (settimeout).


Have you tried removing the image node and replacing it? Something like:

var image = document.getElementById("loader-img");

(You might also need to do image.cloneNode(true) in between the remove and append calls.)

Obviously, your HTML needs to be structured so that this doesn't goof up the display.

But, what knut said applies (posting into a hidden IFRAME or using XHR will give you more control). And I'm not sure what you meant by "it's not a form submit, it is a document.location='url' call", so if you clarify the use case and workflow, I might be able to help more.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.