views:

172

answers:

1

I have a very simple script that slides a message down from the top of the page, then slides it back up after a few seconds. Works fine in FireFox, Chrome, etc, but in IE (6 through 8), after the slideUp completes the div appears at full size for just a moment before disappearing, creating a nasty flash. Any ideas on how to get rid of this?

Here's the page in full:

<html>
    <head>
     <title>Alert Drawer</title>
     <script type="text/javascript" src="../jquery.js"></script>
     <style>
#drawer { 
    background-color: yellow;
    overflow:visible; position:fixed; left:0; top:0;
    text-align:center;
    padding:15px; font-size:18px; border-bottom:2px solid #789;
    width:100%; display:none; z-index:2;
}
     </style>  
    </head>
    <body>
<div id="drawer"></div>
<p>
    <br><br><br><br><br><br><br><br>
    <a href="#doit">Show the alert drawer!</a>
</p>
    </body>
<script type="text/javascript">//<![CDATA[
$(function() {
    var drawer = $('#drawer');
    $('a').click( function() {
     drawer.html("<center>Hey Man!<br>This is a message.</center>");
     drawer.slideDown( function() {
       drawer.css("backgroundColor", "orange");
       setTimeout(function() { drawer.css("backgroundColor", "yellow"); }, 1000);
      }
     );
     setTimeout(function() { drawer.slideUp(); }, 3000);
     return false; 
    });
});
//]]></script>

</html>
+1  A: 

short answer, it's because IE does not know what your html document's doctype is hence it falls back to display it in quirks mode. to remove it, just claim your doctype by adding following code to the head of your page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

to understand thoroughly about this issue and read more about the two different 'modes' most browsers will render your page, please read quirks mode and strict mode on quirksmode.org.

nil
Thanks nil, that did it.
Parand