Reputation: 16900
I have a simple .gif image on my web page. In JavaScript I have:
window.onload = function(){
document.forms[0].submit();
}
I am using Glassfish Server and basically, the process takes a little long even though I have submitted the form as soon as it loads. Thus, the control remains on the page for 2-3 seconds before it is redirected to some other page (as the process is a little complex). My problem is, even though the control remains on the same page why is the .gif not animating?
How do I solve this problem?
Upvotes: 0
Views: 381
Reputation: 833
When the form is submitted, the animation of the gif stops (which is immediate since you submit onload
). This is because the HTTP request is being made. To allow the gif to animate there are a few options:
Use AJAX to submit the form.
Use an iframe - either to submit the form or easier - to load the gif.
Try a few other tricks such as not submitting the form immediately.
window.onload = function () {
setTimeout(function () {
document.forms[0].submit();
}, 1000);
};
In this example, if my theory is correct, at least for 1 second, you will see the gif animating.
Upvotes: 2