onscroll 实现随滚动条浮动的层
<body> <script language="javascript"> window.onscroll=function(){ //document.getElementById("divLeft").style.left=100+parseInt(document.body.scrollLeft) + "px";//水平浮动,竟然是上下浮动就不需要了 document.getElementById("divLeft").style.top=100+parseInt(document.body.scrollTop) + "px";//垂直浮动
/*var divleft_float = 100+$('body').scrollTop()+'px'
$('divleft').css('top','divleft_float');jquery实现*/
} </script> <body> <div id="divLeft" style="position:absolute; width:50px; height:50px;left:100px; top:100px;background-color:#0000FF;"></div> <div style="height:2000px;"></div> </body>