模拟windows control的进度条[3]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 koolfoo 的 blog

   var pos = ((pposition-min)/(max-min))*len;
   eprogress = e.children(0).children(0);
   if(pos>=this.width){
    eprogress.style.width = this.width-4;
    this.currpos = pos;
   }else if(pos<=0){
    eprogress.style.width = 0;
    this.currpos = pos;
   }else{
    eprogress.style.width = pos;
    this.currpos = pos;
   }
   return this.currpos;
  }catch(e){
   alert(e.description);
   return -1;
  }
 }
 function xyupdatepersent(ppersent){   /*从当前位置增长或减小ppersent%,ppersent大于零:增长,否则,减小*/
  try{
   var e = document.all(this.xyprogressid);
   e = e.children(0).children(0);
   var len = this.width;
   var pos = this.currpos;
   len = len*ppersent/100;
   pos += len;
   if(pos>this.width||pos<0){
    return -1;
   }
   e.style.width = pos;
   this.currpos = pos;
   return this.currpos;
  }catch(e){
   alert(e.description);
   return -1;
  }
 }
 function xyupdatetopersent(ppersent){   /*从当前位置增长或减小到ppersent%*/
  try{
   var e = document.all(this.xyprogressid);
   e = e.children(0).children(0);
   var len = this.width;
   var pos = len*ppersent/100;
   if(pos>this.width||pos<0){
    return -1;
   }
   e.style.width = pos;
   this.currpos = pos;
   return this.currpos;
  }catch(e){
   alert(e.description);
   return -1;
  }
 }

 function xynewid(){
  var d = new date();
  var t = "odraw_"+d.gettime().tostring();
  return t;
 }
</script>
</head>
<body topmargin=0 id="bodyid">
<script>
 var xy = new xyprogresslg("kitty");
 xy.setprogressleft(200)
 xy.setprogresstop(200);
 xy.setprogresswidth(200)
 xy.setprogressheight(20)
 xy.setprogressmax(200)
 xy.setprogressmin(50);

 
</script>
<script language="javascript">
function update(){
 xy.updateposition(10)
 settimeout("update()",100);
}

</script>
<button onclick="xy.updatetopersent(20)">update</button>
<button onclick="xy.updateposition(10)">updateposition</button>
<button onclick="update()">autoupdate</button>
</body>
</html>

本文关键:progress,forms,javascript
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top