How to make Floating/fixed widget
This is the code to make any widget fixed/floating:
1. Add this code into your HTML/Javascript widget
<style type='text/css'>
#floatDivWrapper {font-size:11px}
#floatDiv.fixed {position:fixed;top:0px}
</style>
<script type='text/javascript'>//<![ CDATA[
$(document).ready(function(){ var documentHeight=$(document). height();if(documentHeight> 2500){
//$("#floatDivWrapper").css(' position','fixed');$("# floatDiv").css({'position':' fixed','top':30});
var bottomHeight=1200;var msie6=$.browser=='msie'&&$. browser.version<7;if(!msie6){ var top=$('#floatDiv').offset(). top-parseFloat($('#floatDiv'). css('margin-top').replace(/ auto/,0));$(window).scroll( function(event){var y=$(this).scrollTop();if(y>= top&&y<=(documentHeight- bottomHeight)){$('#floatDiv'). addClass('fixed')}else{$('# floatDiv').removeClass('fixed' )}})}}});
//]]></script>
<script type='text/javascript'>//<![ CDATA[
var s=true;function doBlink(){$('.blink').css(' display',function(index,val){ s=!s;return (s)?'block':'none';})}
$(document).ready(function() {setInterval("doBlink()",0)});
//]]></script>
<div class='widget HTML' id='floatDiv'>
widget content
</div>
#floatDivWrapper {font-size:11px}
#floatDiv.fixed {position:fixed;top:0px}
</style>
<script type='text/javascript'>//<![
$(document).ready(function(){
//$("#floatDivWrapper").css('
var bottomHeight=1200;var msie6=$.browser=='msie'&&$.
//]]></script>
<script type='text/javascript'>//<![
var s=true;function doBlink(){$('.blink').css('
$(document).ready(function() {setInterval("doBlink()",0)});
//]]></script>
<div class='widget HTML' id='floatDiv'>
widget content
</div>
2. Customizing number:
- top:0px: The distance from the widget to the top margin during scrolling page.
- documentHeight>2500: the widget will scroll if the post longger than 2500px.
- bottomHeight=1200: 1200px from the bottom, the widget will goes up instead of floating.
Đăng nhận xét