Search code examples
javascriptjqueryshow-hidejquery-events

Using jQuery's .show() on a <div> works, but results in frozen .gifs in Firefox if I try to run along with a redirect


Currently I have the code:

<!-- More html code above -->
<div id="loading" style="display: none;">
    <div align="center">
        <img src="/loading.gif" style="padding:10px;" />
        <div id="lmessage"></div>
    </div>
</div>
<!-- More html code below -->
<!-- ...... -->

<script>
$("#buttonSubmit").click(function () { 
$("#loading").show();
window.location = "/cgi-bin/somscript.py?value="+$('[name=someelement]').val();
});
</script>
</body>
</html>

So basically, I want the div to appear upon the button being clicked. This works, but the .gif (normally animated) only displays the first frame and freezes. The image is properly animated in Safari, but on Firefox it is not. Does anyone know why?

EDIT: Updated the code. If I remove the window.location, the gif works.... why? Do I need to use .delegate or something?


Solution

  • Try window.location.href = url instead of window.location = url (w3Schools reference)