不知道有哪些需要改进的地方或者不兼容的地方
<script type="text/javascript">
var $=function(ID){return document.getElementById(ID);};
var timer=null,speed=36,y=0.1;
window.onscroll=function(){
if(timer) {
clearTimeout(timer);
}
timer=null;
;(function(){
st=document.body.scrollTop||document.documentElement.scrollTop;
if(parseInt($("test").style.top)<st+120){
$("test").style.top=parseInt($("test").style.top)+Math.ceil((st+120-parseInt($("test").style.top))*y)+"px";
} else if(parseInt($("test").style.top)>st+120){
$("test").style.top=parseInt($("test").style.top)-Math.ceil((parseInt($("test").style.top)-120-st)*y)+"px";
} else {
clearTimeout(timer);
timer=null;
}
timer=setTimeout(arguments.callee,speed);
})();
}
//page 287 event2
//page 312 oscroll
</script>

解决方案 »

  1.   

    楼主先把html代码贴出来,至少看下效果吧
      

  2.   

    恩,贴上来了~~<html>
    <head>
    <title></title>
    </head>
    <body>
    <div style="height:2048px;">fasdf</div>
    <div id="test" style="width:120px;height:48px;border:1px solid #e9e9e9;position:absolute;right:4px;top:120px;">fasdf</div><script type="text/javascript">
    var $=function(ID){return document.getElementById(ID);};
    var timer=null,speed=36,y=0.1;
    window.onscroll=function(){
    if(timer) {
    clearTimeout(timer);
    }
    timer=null;
    ;(function(){
    st=document.body.scrollTop||document.documentElement.scrollTop;
    if(parseInt($("test").style.top)<st+120){
    $("test").style.top=parseInt($("test").style.top)+Math.ceil((st+120-parseInt($("test").style.top))*y)+"px";
    } else if(parseInt($("test").style.top)>st+120){
    $("test").style.top=parseInt($("test").style.top)-Math.ceil((parseInt($("test").style.top)-120-st)*y)+"px";
    } else {
    clearTimeout(timer);
    timer=null;
    }
    timer=setTimeout(arguments.callee,speed);
    })();
    }
    //page 287 event2
    //page 312 oscroll
    </script>
    </body>
    </html>
      

  3.   

    ff chorme ie9 都看了下。。还是可以的