运行代码 缩小
汉王
HTML代码
复制 格式化 注释 注释 清空
放大
AخA
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
3
<head>
4
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
5
<title>进度条</title>
6
<style type="text/css">
7
body{margin:0px;padding:0px;}
8
#ibox{line-height:20px;width:300px;height:20px;background:#ccc;text-align:left;margin:100px auto 0 auto;}
9
#iLoading{color:#fff;font-size:12px;line-height:20px;width:0px;height:20px;background:red;text-align:center;position: absolute;}
10
</style>
11
<script type="text/javascript">
12
window.onload=function(){
13
       var idiv=document.getElementById('iLoading');
14
       var ibox=document.getElementById('ibox');
15
       var timer=null;
16
       
17
       timer=setInterval(function(){
18
               var iWidth=idiv.offsetWidth/ibox.offsetWidth*100;
19
               idiv.style.width=idiv.offsetWidth+1+'px';
20
               idiv.innerHTML=Math.round(iWidth)+"%";   
21
               if(iWidth==100){
22
                  clearInterval(timer); 
23
               }
24
            },1);
25
}
26
</script>
27
</head>
28
<body>
29
<div id="ibox">
30
  <div id="iLoading"></div>
31
</div>
32
</body>
33
</html>
CSS代码
复制 格式化 注释 注释 颜色 清空
放大
CSS代码...
x
 
1
JS代码
复制 格式化 注释 注释 清空
放大
JS代码...
xxxxxxxxxx
1
 
1
名称
自己写的JS进度条动画代码
分类
网站常用
描述
使用JavaScript写的网页进度条动画,演示网页的加载进度,经过多次调试,终于将兼容性做到了最好,在此提醒网友:且记要把速度 iSpeed设为1,设为其它值可能导致IE6下不兼容。
收藏