Floating message | Banner for IE6 users using jquery
April 1, 2010 at 4:33 am Leave a comment
CSS
———————–
#message_box {
position: absolute;
top: 0; left: 0;
z-index: 10;
background:#ffc;
padding:5px;
border:1px solid #CCCCCC;
text-align:center;
font-weight:bold;
width:99%;
}
Script
———————-
<script type=”text/javascript” language=”javascript”>
$(document).ready(function()
{
//scroll the message box to the top offset of browser’s scrool bar
$(window).scroll(function()
{
$(‘#message_box’).animate({top:$(window).scrollTop()+”px” },{queue: false, duration: 350});
if($(window).scrollTop()==0){
$(‘#message_box’).animate({top:$(window).scrollTop()+80+”px” },{queue: false, duration: 350});
}
});
//when the close button at right corner of the message box is clicked
$(‘#close_message’).click(function()
{
//the messagebox gets scrool down with top property and gets hidden with zero opacity
$(‘#message_box’).animate({ top:”+=15px”,opacity:0 }, “slow”);
});
});
</script>
HTML
—————————
<body>
<div id=”message_box”><img id=”close_message” style=”float:right;cursor:pointer” src=”12-em-cross.png” />The floating message goes here</div>
<div>
content goes here
</div>
</body>
Entry filed under: jquery.
Trackback this post | Subscribe to the comments via RSS Feed