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="X-UA-Compatible" content="IE=9" />
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <title>页面加载进度条</title>
7 <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
8 <script type="text/javascript">
9 var etControl = {};
10 etControl.process = function (config) {
11 /*需要放在html中的body标签后面使用本控件*/
12
13 var count = 0;
14 var id = "loading";
15 var el = "#" + id;
16
17 $("body").append('<div id="' + id + '"></div>');
18
19 var divTxt = "#" + id + " div";
20 $(el).html("<div></div>");
21 $(el).attr("style", " 100px;height: 12px;background: #A0DB0E;padding: 5px;position: fixed;left: 0;top: 0;font-size:12px;");
22 $(divTxt).attr("style", " 1px;height: 12px;background: #F1FF4D;");
23
24 /*更新进度条*/
25 this.updateProcess = function (percent) {
26 setTimeout(function () { $(divTxt).animate({ percent + "px" }).text(percent + "%") }, ++count * 500);
27 if (percent == 100) { /*100%就从页面移除loading标签*/
28 setTimeout(function () {
29 $(el).hide(500);
30 setTimeout(function () { $(el).remove() }, 500);
31 }, count * 500 + 800);
32 }
33 };
34 }
35
36 </script>
37 </head>
38 <body>
39
40 </body>
41
42 <script type="text/javascript">
43 /*需要放在body标签后面,然后在适当的位置调用updateProcess方法*/
44 var p = new etControl.process();
45 p.updateProcess(34);
46 p.updateProcess(57);
47 p.updateProcess(62);
48 p.updateProcess(90);
49 p.updateProcess(100);
50 </script>
51
52 </html>
复制过来就是方便自己查看而已
来自http://www.cnblogs.com/timy/archive/2011/12/07/2279200.html
如有版权问题,请联系我删除