<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
js进度条效果-www.jb200.com</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--以下代码加到<head>与</head>之间-->
<style type="text/css">
body{margin:0px;padding:0px;}
#ibox{
line-height:20px;width:300px;height:20px;background:#ccc;text-align:left;margin:100px auto 0 auto;}
#iLoading{color:#fff;font-size:12px;line-height:20px;width:0px;height:20px;background:red;text-align:center;position: absolute;}
</style>
<script type="text/
javascript">
window.onload=function(){
var idiv=document.getElementById('iLoading');
var ibox=document.getElementById('ibox');
var timer=null;
timer=setInterval(function(){
var iWidth=idiv.offsetWidth/ibox.offsetWidth*100;
idiv.style.width=idiv.offsetWidth+1+'px';
idiv.innerHTML=Math.round(iWidth)+"%";
if(iWidth==100){
clearInterval(timer);
}
},1);
}
</script>
</head>
<body>
<!--以下代码加到<body>与</body>之间-->
<div id="ibox">
<div id="iLoading"></div>
</div>
</body>
</html>