如果MYIE出现不了这种效果,可能是被设置"启用浮动广告过滤",把勾选去掉应该就可以了! 本代码摘自经典论坛 代码如下: <script language="javascript"> function moveLayerBy(ye,x,y) { ye.style.left=(parseInt(ye.style.left)+x)+"px"; ye.style.top=(parseInt(ye.style.top)+y)+"px"; } function getScrollX() { return document.body.scrollLeft; } function getScrollY() { return document.body.scrollTop; } function floatIt() { var floatOffset=5; var ye=document.getElementById("floating"); if (typeof(ye.sX)=="undefined") { ye.sX=0; } if (typeof(ye.sY)=="undefined") { ye.sY=0; }
var sx=getScrollX(), sy=getScrollY(); if (ye.sX!=sx || ye.sY!=sy) { var mx=sx>ye.sX?Math.ceil:Math.floor, my=sy>ye.sY?Math.ceil:Math.floor; var dx=mx((sx-ye.sX)/floatOffset), dy=my((sy-ye.sY)/floatOffset); ye.sX+=dx; ye.sY+=dy; moveLayerBy(ye,dx,dy); }
setTimeout("floatIt()",100); } </script> <body onload="floatIt()"> <table height=1500><tr><td> </td></tr></table> <div style="position:absolute; top:10px; left:0px; border:1px dotted #00fd00; padding:10px" id="floating">
<a href="h99.html">Float Layer</a> </div>
----------------------------------------
|