前端js實現動態更新進度條-9

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 進度條 </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="text/html">
<META NAME="Description" CONTENT="有關windows中進度條的實現">
<style type="text/css">
 #out{width:300px;height:20px;background:#EEE;}
 #in{width:10px; height:20px;background:#778899;color:white;text-align:center;}
 #font_color{background:yellow;text-align:center;color:white;}
</style>
</HEAD>
<div onload="start();" >
 <div id='out'>
  <div id="in" style="width:10%">10%</div>
 <div>
 <script type="text/javascript">
  i=0;
  function start()
  {
    ba=setInterval("begin()",100);//setInterval 返回的是一個全局變量,一個間隔數值.這個數值是表示調用setInterval的次數
  }
  function begin()
  {
   i+=1;
  if(i<=100)
  {
   document.getElementById("in").style.width=i+"%";
      document.getElementById("in").innerHTML=i+"%";}
  else
  {
      clearInterval(ba);
   document.getElementById("out").style.display="none";
   document.write("<span  style='background:yellow;text-align:center;color:white;'>加載成功</span>");
  }
  }
 </script>
</div>
</HTML>javascript

相關文章
相關標籤/搜索