本节内容:
JS Loading页面的实现代码。
实现思路:
1,当前页面:
2,遮罩层:
3,Loading展示层:
这里的loading层图片,大家自己准备吧。
完整代码:
最终效果:
另外一种实现方法:
利用JS不断的改变html标签的value值,达到加载提示的效果
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS Loading页面-www.jb200.com</title>
<!-- <script src="Scripts/jquery-1.8.2.js"></script>-->
<style type="text/css">
#tb {
width: 100%;
height: 100%;
line-height: 10px;
}
#tb tr td {
text-align: center;
}
.progressbar {
font-family: Arial;
font-weight: bolder;
color: gray;
background-color: white;
padding: 0px;
border-style: none;
}
.percent {
font-family: Arial;
color: gray;
text-align: center;
border-width: medium;
border-style: none;
}
</style>
<script type="text/javascript">
var bar = 0;
var step = "||";
/*
*第一种方式即 :$(document).ready(function(){.....});
*/
//$(function () {
// progress();
//});
/*
*第二种方式
*/
//window.onload = function () {
// progress();
//}
/*
*第三种方式模拟 $(document).ready(function(){.....});
*/
(function () {
var ie = !!(window.attachEvent && !window.opera);
var wk = /webkit/(d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
var fn = [];
var run = function () { for (var i = 0; i < fn.length; i++) fn[i](); };
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener)
return d.addEventListener('DOMContentLoaded', f, false);
if (fn.push(f) > 1) return;
if (ie)
(function () {
try { d.documentElement.doScroll('left'); run(); }
catch (err) { setTimeout(arguments.callee, 0); }
})();
else if (wk)
var t = setInterval(function () {
if (/^(loaded|complete)$/.test(d.readyState))
clearInterval(t), run();
}, 0);
};
})();
document.ready(function () {
progress();
});
function progress() {
bar = bar + 2;
step = step + "||";
document.getElementById("percent").value = bar + "%";
document.getElementById("progressbar").value = step;
if (bar <= 98) {
setTimeout("progress()", 100);
}
}
</script>
</head>
<body>
<table id="tb">
<tr>
<td>
<input type="text" size="50" class="percent" id="percent" /></td>
</tr>
<tr>
<td>
<input type="text" size="50" class="progressbar" id="progressbar" /></td>
</tr>
</table>
</body>
</html>
最终效果: