漂亮的進度條(js代碼)

來源:互聯網
上載者:User
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
  <div style="background: url('http://screenprint2007.cpp114.com/UserFiles/20070412155452218.gif') no-repeat;text-align:center;width:256px;height:18px;position:absolute;top:110;left:10;font-size:13px">

<div id="proc" style="background: url('http://screenprint2007.cpp114.com/UserFiles/20070412155424937.gif');position:absolute;top:0;left:0;width:0px;height:18px;font-size:13px"></div>
<div style="position:absolute;top:2;left:0;width:256px;height:18px;text-align:center;font-size:13px;background:transparent">&nbsp;</div>
</div>
<br><br><br><br><br><br>
<input type="button" value="start" onclick="processBar.changeMode();if(processBar.isMoving){this.value='Stop';}else{this.value='Start';}"><script>
document.execCommand("BackgroundImageCache",false,true);
function ProcessBar(obj){
   this.isMoving = false;
   this.maxLength = parseInt(obj.parentNode.style.width.replace("px",""));
   this.nowLength = parseInt(obj.style.width.replace("px",""));
   this.moveInterval = 100;
   this.moveRange = 1;
   this.timer;
   this.obj = obj;

   ProcessBar.nowObj = this;

   this.changeMode = function(){
                this.isMoving = !this.isMoving;
                
                if(this.isMoving){
                        this.timer = window.setInterval(ProcessBar.nowObj.moving, this.moveInterval);
                }else{
                        window.clearInterval(this.timer);
                }
   }

   this.moving = function(){
        ProcessBar.nowObj.nowLength += ProcessBar.nowObj.moveRange;
                ProcessBar.nowObj.obj.style.width = ProcessBar.nowObj.nowLength;

                ProcessBar.nowObj.obj.parentNode.lastChild.firstChild.data = Math.ceil((ProcessBar.nowObj.nowLength/ProcessBar.nowObj.maxLength)*100) + "%";

                if(ProcessBar.nowObj.nowLength >= ProcessBar.nowObj.maxLength){
                        window.clearInterval(ProcessBar.nowObj.timer);
                        ProcessBar.nowObj.obj.parentNode.lastChild.firstChild.data = "Complete!";
                }
   }

   
}

var processBar = new ProcessBar(proc);

</script> </BODY>
</HTML>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.