IE GIF Animation Problem

By Dag, on December 30th, 2016

If you click a link or submit a form in IE, any gif image will stop its current animation and wait for the new document to load. This is because the IE browser unloads everything once it starts loading a new document, including the animation mechanisms of gif image files.

This is can be annoying in cases where you want a loading animation to appear when uploading POST data or just want some animation while a heavy page is preparing. The trick is to load the animation AFTER IE has unloaded everything. One way to do this is by using javascript and the setTimeout() function.

Solution:

function viewAnimation()
{
// DHTML function for viewing animation.
}
function viewAnimationLoad()
{
/*
Start this function instead of the other to make IE
start the viewAnimation() function 500 milliseconds after
it has started loading a new document. This will make
the animation work.
*/
setTimeout('viewAnimation()',500);
}

TIP: If you experience only a blank image until you resize the window, then it can be fixed by explicitly setting a width in the image layer CSS class.