IE 7 will not show animated GIF and then redirect... no animation is shown

Discussion in 'JavaScript' started by winterheat, Jan 23, 2009.

  1. #1
    it seems that if i show an animated GIF and then use

    top.location.href = "http://...";

    to do a redirect, Firefox or Chrome will both show the animated GIF fine, but IE 7 will show the animated GIF only for its first frame. It is not animated at all.

    the code is like this:

    <img id="progressLoop" src="progressLoop.gif" style="visibility:hidden" />
    
    <select onchange="go()">
    	<option value="1">1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>
    </select>
    
    <script>
    function go() {
    	document.getElementById('progressLoop').style.visibility = 'visible';
    	top.location.href = 'http://www.somesite.com/test_redirect.php?i=' + Math.random();
    }
    </script>
    
    Code (markup):

    it is the same if i use display: none instead of visibility. Further, if i use width: 0, and then set it to 16px before redirect, it is the same thing: no animation on IE 7.

    the only way I can get it to work is by using setTimeout(redirect, 1000) to do the redirection so that there is a 1 second delay. Unfortunately, I need to do this using FBJS which is Facebook's javascript and they have no setTimeout() support at all. I wonder if this can be done on IE 7 without setTimeout() at all? Thanks very much.
     
    winterheat, Jan 23, 2009 IP