Go back

Animated gifs stop animating in IE

An annoying bug/ feature of Internet Explorer is that animated gifs stop animating the moment you click a link to navigate to another page. Other things can stop them animating too: I recently found that a flash-based file uploader that we use triggers this bug when it finishes the upload.

Fortunately it's not to hard to work around. If you reassign the value of the src attribute of the <img> tag, the animation starts again.

jQuery makes it easy to reassign all such tags in one fell swoop:

<span style="color: #008000">//codesnippet:7660712A-6D8A-4820-A99F-751F44A57AD2</span>
<span style="color: #0000ff">function</span> fixAnimatedGifsDamnYouInternetExplorer()
{
    $(&quot;<span style="color: #8b0000">img</span>&quot;).each(<span style="color: #0000ff">function</span>()
    {
        <span style="color: #0000ff">this</span>.src = <span style="color: #0000ff">this</span>.src;
    });
}

In my case, I called this function when my upload completed, but you could easily attach it to the click event of every link on your page.

Got a project? Let's work together

Compsoft is a remote working company except for Thursdays when we work together from the Alton Maltings in Alton, Hampshire (UK). Our registered address is detailed below. We'd be delighted to have either a virtual chat with you or to make arrangements to meet in person.