动画进度条以显示网页的进度

时间:2013-08-12 02:20:56

标签: javascript progress-bar

我的页面顶部有一个进度条,我希望该栏显示加载网页的进度。加载整个页面时,我希望栏显示100%。我很确定我需要列出一个'$(window).load();的变量但我不知道在哪里。

我的代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<style>
progress {
width: 100%;
height: 5px;
top: 0;
left: 0;
position: absolute;
color: #1990c8;
appearance: none;
-webkit-appearance: none;
-o-appearance: none;
}
progress::-moz-progress-bar { 
background: #1990c8;
}
progress::-webkit-progress-value {
background: #1990c8;
}
progress::-webkit-progress-bar {
background: #e1e1e1;
}
</style>
</head>
<body>
<progress id="progressbar" value="0" max="100"></progress>
<span id="status"></span>
<script type="text/javascript" language="javascript">
function progressbaranimation(a) {
var bar = document.getElementById('progressbar');
bar.value = a;
a++;
var sim = setTimeout("progressbaranimation("+a+")");
}
var amount = 0;
progressbaranimation(amount);
</script>
<img src="http://media.npr.org/images/picture-show-flickr-promo.jpg">
<img src="http://dd508hmafkqws.cloudfront.net/sites/default/files/mediaimages/gallery/2012/Dec/AA-502716%20(1).jpg">
</body>
</html>

1 个答案:

答案 0 :(得分:0)

你可以用基本的javascript做到这一点。 请检查此http://yensdesign.com/2008/11/how-to-create-a-stylish-loading-bar-as-gmail-in-javascript/