Javascript进度条

来源:互联网 发布:航天信息开票软件下载 编辑:程序博客网 时间:2024/05/21 22:38
<!DOCTYPE html>
<html>
<head>
<title>进度条</title>
<meta charset="utf-8">
<style type="text/css">
   .content{
width: 80%;
margin-left:auto;
margin-right: auto;
}
.progress{
width:100%;
height:20px;

border: 1px solid blue;
}
.progress_bar{
width:10%;
height:20px;
margin-top:-16px;
background-color:green;
}
p{
color: red;
}
</style>
<div class="content">
<h2 align="center">开始下载</h2>
<div class="progress">
<div id="progress_bar" class="progress_bar">
<p id="data"></p>
    </div>
</div>
</div>
<script type="text/javascript">
var time=0;
function progress(){
time++;
document.getElementById('data').innerHTML=time+"%";
document.getElementById("progress_bar").style.width=time+'%';
if(time!=100)setTimeout('progress()',100);
    else document.getElementById('data').innerHTML="下载完成。";
}
progress();
</script>
</body>
</html>

0 0