首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

自个儿做的一个跟随滚动的代码,求拍砖

2012-07-28 
自己做的一个跟随滚动的代码,求拍砖!不知道有哪些需要改进的地方或者不兼容的地方JScript codescript typ

自己做的一个跟随滚动的代码,求拍砖!
不知道有哪些需要改进的地方或者不兼容的地方

JScript code
<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>




[解决办法]
楼主先把html代码贴出来,至少看下效果吧
[解决办法]
好像少了点啥
[解决办法]
ff chorme ie9 都看了下。。还是可以的。。。
[解决办法]
效果还不错就是就是效果写固定了,最好能提炼封装下,让别人用只需要设定参数不需要改动你的代码。

热点排行