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", "width: 100px;height: 12px;background: #A0DB0E;padding: 5px;position: fixed;left: 0;top: 0;font-size:12px;"); 22 $(divTxt).attr("style", "width: 1px;height: 12px;background: #F1FF4D;"); 23 24 /*更新進度條*/ 25 this.updateProcess = function (percent) { 26 setTimeout(function () { $(divTxt).animate({ width: 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若有版權問題,請聯繫我刪除