Animated GIF in IE stopping

Does anyone know a work around to make animated GIF’s continue to be animated after you click a link or submit a form on the page your on in IE? This works fine in other browsers.


Animated gif in IE stopping in case of multiple postbacks

I am using ajax to retrieve xml and xsl to create output HTML. when the processing is done, we are showing loading gif icons. For IE browser, the loading gif stops playing.. it freezes when there occu

PHP crop animated gif

Is it possible somehow to crop animated gif with builtin php libraries, ie without using Imagick etc? Thanks 😉

Animated gif freezes in UpdateProgress in IE8

I am using update progess to show the animated gif saying Loading… I am testing in IE 8 and the animation freezes. I have come to know that IE 6 & 8 have a bug to handle this and have found ce

IE7 Animated GIF Appears as a Static Image?

After a button is clicked to start a process on my web app, I show a small loading gif (animated) that rotates to indicate to the user something is happening. I put the gif img in place of the button

animated .GIF and Java

What’s the code for displaying an animated .gif inside an applet?

Show animated gif in Java

How to display animated gif in Java application?

Display Animated GIF

I want to display animated GIF images in my aplication. As I found out the hard way Android doesn’t support animated GIF natively. However it can display animations using AnimationDrawable: http://dev

Android: Animated gif [duplicate]

This question already has an answer here: Display Animated GIF 14 answers I’ve got an animated gif which is a loading bar. The image displays but there is no animation, how would I get it to an

Animated gif in android

i want to use animated gif in android. hows this possible? is it compatible in 1.6,2.0?

how to delay call to JS function – animated gif not working in IE

I’m struggling to get an animated gif to run in IE. Works in all other browsers, but in IE it just freezes. I’ve researched this and looks like a delay using setTimeout might work. Not too sure how I


It’s a known bug (limitation) of IE. You could use javascript to solve it. Just preload image and change source (<img src=”?”>) of freezing image to that preloaded image on “onbeforeunload” action.

IE assumes that the clicking of a link heralds a new navigation where the current page contents will be replaced. As part of the process for perparing for that it halts the code that animates the GIFs. I doubt there is anything you can do about it (unless you aren’t actually navigating in which case use return false in the onclick event).

The accepted solution did not work for me.

After some more research I came across this workaround, and it actually does work.

Here is the gist of it:

function showProgress() {
    var pb = document.getElementById("progressBar");
    pb.innerHTML = '<img src="./progress-bar.gif" width="200" height ="40"/>'; = '';

and in your html:

<input type="submit" value="Submit" onclick="showProgress()" />
<div id="progressBar" style="display: none;">
    <img src="./progress-bar.gif" width="200" height ="40"/>

So when the form is submitted, the <img/> tag is inserted, and for some reason it is not affected by the ie animation issues.

Tested in Firefox, ie6, ie7 and ie8.

Related to this I had to find a fix where animated gifs were used as a background image to ensure styling was kept to the stylesheet. A similar fix worked for me there too… my script went something like this (I’m using jQuery to make it easier to get the computed background style – how to do that without jQuery is a topic for another post):

var spinner = <give me a spinner element>

window.onbeforeunload = function() {
  bg_image = $(spinner).css('background-image'); = 'none'; = bg_image;

[EDIT] With a bit more testing I’ve just realised that this doesn’t work with background images in IE8. I’ve been trying everything I can think of to get IE8 to render a gif animation wile loading a page, but it doesn’t look possible at this time.

old question, but posting this for fellow googlers:

Spin.js DOES WORK for this use case:

Here’s what I did. All you have to to is to break up your GIF to say 10 images (in this case i started with 01.gif and ended with 10.gif) and specify the directory where you keep them.


<div id="tester"></div>


function pad2(number) {   
    return (number < 10 ? '0' : '') + number 
    dirURL = 'path/to/your/images/folder',
    ajaxLoader = document.createElement('img');
ajaxLoader.className = 'ajax-image-loader';
function set(i) {
    if (i > 10) i = 1;    
    img.src = dirURL + pad2(i) + '.gif';
    setTimeout(function() {
    }, 100);    

This method works with IE7, IE8 and IE9 (althought for IE9 you could use spin.js). NOTE: I have not tested this in IE6 since I have no machine running a browser from the 60s, although the method is so simple it probably works even in IE6 and lower.

I realize that this is an old question and that by now the original posters have each found a solution that works for them, but I ran across this issue and found that VML tags do not fall victim to this IE bug. Animated GIFs still move during page unload when placed on the IE browser using VML tags.

Notice I detected VML first before making the decision to use VML tags so this is working in FireFox and other browsers using normal animated GIF behavior.

Here’s how I solved this.

<input class="myExitButton" type="button" value="Click me"  />

<div class="loadingNextPage" style="display:none" >
    <span style="left:-24px; POSITION: relative; WIDTH: 48px; DISPLAY: inline-block; HEIGHT: 48px" class="spinnerImageVml"><?xml:namespace prefix="rvml" ns = "urn:schemas-microsoft-com:vml" /><rvml:group style="POSITION: absolute; WIDTH: 48px; HEIGHT: 48px; rotation: 1deg" class="rvml" coordsize = "47,47"><rvml:image style="POSITION: absolute; WIDTH: 48px; HEIGHT: 48px; TOP: 0px; LEFT: 0px" class="rvml" src="/images/loading_gray.gif" coordsize="21600,21600"></rvml:image></rvml:group></span>
    <img class="spinnerImage" src="/images/loading_gray.gif" alt="loading..." />
    <div>Just one moment while we access this information...</div>

<script language="javascript" type="text/javascript">
    window.LoadProgress = (function (progress, $) {

        var getdialogHeight = function (height) {
            var isIE = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
            if (isIE) {
                return height + 'px';
            return height;

        var isVmlSupported = function () {
            var a = document.body.appendChild(document.createElement('div'));
            a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
            var b = a.firstChild;
   = "url(#default#VML)";
            var supported = b ? typeof b.adj == "object" : true;
            return supported;

        var showAnimationDuringPageUnload = function () {
            if (isVmlSupported()) {
                $(".loadingNextPage > .spinnerImage").hide();
            else {
                $(".loadingNextPage > .spinnerImageVml").hide();

        var openLoadingMessage = function () {
                modal: true,
                closeOnEscape: true,
                title: 'Please wait...',
                closeText: 'x',
                height: getdialogHeight(200),
                buttons: {
                    "Close": function () {

        $('.myExitButton').click(function () {
            window.location.href = '';

        return progress;
    })(window.LoadProgress || {}, window.jQuery);

Naturally, this relies on jQuery, jQueryUI and requires an animated GIF of some type (“/images/loading_gray.gif”).

In personal experience using spin.js fixed loads of problems. Recommend it to everyone with any spinner problems.


$("#WhereYouWantTheImageToAppear").html('<img src="./Animated.gif" />');

I encountered this problem when trying to show a loading gif while a form submit was processing. It had an added layer of fun in that the same onsubmit had to run a validator to make sure the form was correct. Like everyone else (on every IE/gif form post on the internet) I couldn’t get the loading spinner to “spin” in IE (and, in my case, validate/submit the form). While looking through advice on I found a post by ev13wt that suggested the problem was “… that IE doesn’t render the image as animated cause it was invisible when it was rendered.” That made sense. His solution:

Leave blank where the gif would go and use JavaScript to set the source in the onsubmit function – document.getElementById(‘loadingGif’).src = “path to gif file”.

Here’s how I implemented it:

<script type="text/javascript">
    function validateForm(form) {

        if (isNotEmptyid(form.A)) {
            if (isLen4(form.B)) {        
                if (isNotEmptydt(form.C)) {
                    if (isNumber(form.D)) {        
                        if (isLen6(form.E)){
                            if (isNotEmptynum(form.F)) {
                                if (isLen5(form.G)){
                                    document.getElementById('tabs').style.display = "none";                
                                    document.getElementById('dvloader').style.display = "block";                
                                    document.getElementById('loadingGif').src = "/images/ajax-loader.gif"; 
                                    return true;
        return false;   

<form name="payo" action="process" method="post" onsubmit="return validateForm(this)">
    <!-- FORM INPUTS... -->
    <input type="submit" name="submit" value=" Authorize ">

    <div style="display:none" id="dvloader">  
        <img id="loadingGif" src="" alt="Animated Image that appears during processing of document." />
        Working... this process may take several minutes.


This worked well for me in all browsers!

Just had a similar issue. These worked perfectly for me.

$('#myElement').prepend('<img src="/path/to/img.gif" alt="My Gif" title="Loading" />');

$('<img src="/path/to/img.gif" alt="My Gif" title="Loading" />').prependTo('#myElement');

Another idea was to use jQuery’s .load(); to load and then prepend the image.

Works in IE 7+

Here’s a jsFiddle that works just fine on form submit with method=”post”. The spinner is added on form submit event.

$("form").bind("submit", onFormSubmit);

function onFormSubmit() {
    setTimeout(showSpinner, 1);

function showSpinner() {
    $("body").append($('<img id="spinner" src="spinner.gif" alt="Spinner" />'));

See jsFiddle code here

Test it in your IE browser here

Building on @danfolkes’ answer, this worked for me in IE 8 and ASP.NET MVC3.

In our _Layout.cshtml

<body style="min-width: 800px">
    <div id="progress">
        <div style="min-height: 200px">
        <div id="throbber">
            <img src="../../Content/ajax-loader.gif" alt="Progress" style="display: block;
                margin-left: auto; margin-right: auto" />
    <div id="main">

<<< content here >>> …

<script type="text/javascript" language="javascript">
    function ShowThrobber() {
        // Work around IE bug which freezes gifs
        if (navigator.appName == 'Microsoft Internet Explorer') {
            // Work around IE bug which freezes gifs
            $("#throbber").html('<img src="../../Content/ajax-loader.gif" alt="Progress" style="display: block; margin-left: auto; margin-right: auto"/>');
<script type="text/javascript" language="javascript">
    function HideThrobber() {
<script type="text/javascript" language="javascript">
    $(document).ready(function () {

And in our navigation links:

<input type="submit" value="Finish" class="submit-link" onclick="ShowThrobber()"/>


@Html.ActionLink("DoSometthing", "MyController", new { Model.SomeProperty }, new { onclick = "ShowThrobber()" })

Very, very late to answer this one, but I’ve just discovered that using a background-image that is encoded as a base64 URI in the CSS, rather than held as a separate image, continues to animate in IE8.

I came upon this post, and while it has already been answered, felt I should post some information that helped me with this problem specific to IE 10, and might help others arriving at this post with a similar problem.

I was baffled how animated gifs were just not displaying in IE 10 and then found this gem.

ToolsInternet OptionsAdvancedMultiMediaPlay animations in webpages

hope this helps.

I had this same problem, common also to other borwsers like Firefox. Finally I discovered that dynamically create an element with animated gif inside at form submit did not animate, so I developed the following workaorund.

1) At document.ready(), each FORM found in page, receive position:relative property and then to each one is attached an invisible

2) After this, assuming that each submit value of my website is identified by btn-primary css class, again at document.ready(), I look for these buttons, traverse to the FORM parent of each one, and at form submit, I fire showOverlayOnFormExecution(this,true); function, passing clicked button and a boolean that toggle visibility of

$(document).ready(function() {

  //Append LOADING image to all forms
  $('form').css('position','relative').append('<div class="bg-overlay" style="display:none;"><img src="/images/loading.gif"></div>');

  //At form submit, fires a specific function
  $('form .btn-primary').closest('form').submit(function (e) {

CSS for is the following:


.bg-overlay img
  margin-left:-40px; //my loading images is 80x80 px. This is done to center it horizontally and vertically.

3) At any form submit, the following function is fired to show a semi-white background overlay all over it (that deny ability to interact again with form) and an animated gif inside it (that visually show a loading action).

function showOverlayOnFormExecution(clicked_button, showOrNot) 
    if(showOrNot == 1)
        //Add "content" of #bg-overlay_container (copying it) to the confrm that contains clicked button 
        $('form .bg-overlay').hide();

Showing animated gif at form submit, instead of appending it at this event, solves “gif animation freeze” problem of various browsers (as said, I found this problem in IE and Firefox, not in Chrome)

Found this solution at and it WORKS! Simply re-load image before setting to visible. Call the following Javascript function from your button’s onclick:

function showLoader()
   //*** Reload the image for IE ***
   //*** Let's make the image visible ***
   document.getElementById('loader').style.visibility = 'visible';