论坛首页 AJAX版 JavaScript

网页元素跟随BODY上下滚动JS组件

浏览 225 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2008-03-28
UpDownRoller.prototype.uid=100;
 function UpDownRoller(objID,selfName){
   var obj=document.getElementById(objID);
   obj.style.position="relative";
   obj.style.zIndex=this.uid++;
   this.target=obj;
   this.autoRoll=false;
   this.selfName=selfName;
   this.timerID=null;
 }
 UpDownRoller.prototype.setAutoRoll=function(b){
   if(this.autoRoll==b){
      return null;
   }
   this.autoRoll=b;
   if(b){
     if(this.timerID){
        window.clearInterval(this.timerID);
     }
     this.timerID=window.setInterval(this.selfName+".roll()",10);
   }else{
     this.target.style.pixelTop=0;
   }
 }
 UpDownRoller.prototype.roll=function(){
   if(!this.autoRoll){
       return false;
   }
   var t=this.target;
   t.style.pixelTop=document.body.scrollTop;
 }
 if(document.getElementById("floater")){
   var ft=new UpDownRoller("floater","ft");
   ft.setAutoRoll(true);
 }
   
论坛首页 AJAX版 JavaScript

跳转论坛:
JavaEye推荐