亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

jQuery 頁面載入進(jìn)度條 (必有一款適合你----綜

系統(tǒng) 2180 0

第一種方法:

?

頁面 Loading 條基本人人都會用。它的原理很簡單:在頁頭放置一個文字或者圖片的 loading 狀態(tài),然后頁尾載入一段 JS 隱藏掉,即根據(jù)瀏覽器的載入順序來實(shí)現(xiàn)的簡易 Loading 狀態(tài)條。

?

loading Process traditional

?

上圖展示了傳統(tǒng) Wordpress 模板在瀏覽器中的載入順序,Loading 條的出現(xiàn)和消失分布于頭尾。

?

new loading bar

?

如果我們在頁面的不同位置放置多個 JS ,每個 JS 用于逐步增加 Loading 條的寬度,那么這個 Loading 條無疑會更具實(shí)用價值。它在一定程度上緩解了訪客等待載入的枯燥感,同時還能客觀反映頁面載入的進(jìn)度。若再配以 jQuery 內(nèi)建的動畫效果,其完全可以與瀏覽器自帶的狀態(tài)條媲美。

先來看一個演示: 地址

?

要得到演示上的進(jìn)度條效果, 首先 ,引入 jQuery 框架(一定要放在頁頭 <head> 標(biāo)簽內(nèi))。然后在 <body> 標(biāo)簽起始位置放置:

<div id="loading"><div></div></div>

CSS 可以這么寫:

#loading {
width:100px;
height:20px;
background:#A0DB0E;
padding:5px;
position:fixed;
left:0;
top:0;
}
#loading div {
width:1px;
height:20px;
background:#F1FF4D;
}

準(zhǔn)備工作到這里就做好了。

接著 ,請隨意發(fā)揮,依照你對圖二的理解,在模板各個部分的適當(dāng)位置放置:

<script type="text/javascript">
$("#loading div").animate({width:" 16px "})
</script>

其中紅色數(shù)值應(yīng)該隨載入順序逐步增加,直到 footer.php。另外別忘了在 footer.php 最末尾放上:

<script type="text/javascript">
$("#loading").fadeOut()
</script>

用于載入完畢后隱藏進(jìn)度條。

?


第二種

?

?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Loading Status Bar</title>
<meta name="robots" content="noindex,follow" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
	document.writeln("<style type=\"text\/css\">#loading{width:100px;height:20px;background:#A0DB0E;padding:5px;position:fixed;left:0;top:0}#loading div{width:1px;height:20px;background:#F1FF4D;font:10px/20px Arial}<\/style>");
</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<noscript>您的瀏覽器不支持 Javascript</noscript>

<div id="loading">
	<div></div>
</div>

<? for($i=0;$i<100000;$i++){ echo $i;} ?>
	<script type="text/javascript">$("#loading div").animate({width:"16px"}).text("16%")</script>
<? echo '<br><br><br>'; for($i=0;$i<100000;$i++){ echo $i;} ?>

<script type="text/javascript">setTimeout(function(){$("#loading div").animate({width:"34px"}).text("34%")},500)</script>
<script type="text/javascript">setTimeout(function(){$("#loading div").animate({width:"67px"}).text("67%")},1000)</script>
<script type="text/javascript">setTimeout(function(){$("#loading div").animate({width:"82px"}).text("82%")},1500)</script>
<script type="text/javascript">setTimeout(function(){$("#loading div").animate({width:"100px"}).text("100%")},2000)</script>
<script type="text/javascript">setTimeout(function(){$("#loading").hide(500)},3000)</script>

</body>
</html>
  
?

第三種 導(dǎo)向型

?

?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Loading</title>
<style type="text/css">
.proccess{
	border:1px solid;
	width:8px;
	height:8px;
	background:#ffffff;
	margin:3px;
}
</style>

<script language="JavaScript">
	var url = 'http://deographics.com/';
</script>

</head>

<body  onLoad="location.href = url;" style='overflow:hidden; overflow-y:hidden'>
	<div align=center>
		<font class=fontbig>友情提示,頁面正在加載中,請等待......</font>
		<div align="center">
			<form method="post" name="proccess">
				<script type="text/javascript"> 
					for(i=0;i<30;i++){
						document.write("<input class=proccess>");
					}
				</script>
			</form>
		</div>

		<div align="center">
			<script language=JavaScript>
				var p=0,j=0;
				var c=new Array('lightskyblue','white')
				setInterval('proccess();',100)
				function proccess(){
					document.forms.proccess.elements[p].style.background=c[j]; p+=1;
					if(p==30){ p=0;j=1-j; }
				}
			</script>
		</div>
	</div>

	<div align="center">
		<script>
			if (document.layers){
				document.write('<Layer src="' + url + ' " visibility="hide"> </Layer>');
			}else if (document.all || document.getElementById){
				document.write('<iframe src="' + url + '" style="visibility: hidden;"></iframe>');
			}else{
				location.href = url;
			}
		</script>
	</div>
</body>
</html>
  
?
?
第四種 iframe loading

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Iframe Loading</title>
</head>

<body>   
	<div id="load"><img src="http://sysimages.tq.cn/images/analysis_images/ajax-loader.gif" />&nbsp;loading...</div>
	<iframe style="visibility:hidden" onreadystatechange="stateChangeIE(this)" onload="stateChangeFirefox(this)" name="callframe" id="callframe" width="420" height="100" frameborder="0" scrolling="no" marginheight="0"></iframe>

	<script>   
		function stateChangeIE(_frame){
			if (_frame.readyState=="interactive"){ //state: loading ,interactive, complete
				var loader = document.getElementById("load");
				loader.innerHTML  = "";
				loader.style.display = "none";  
				_frame.style.visibility = "visible";   
			}   
		}

		function stateChangeFirefox(_frame){
			var loader = document.getElementById("load");
			loader.innerHTML  = "";
			loader.style.display = "none";  
			_frame.style.visibility = "visible";   
		}

		callframe.location.;
	</script>   
</body>
</html>
    

解釋:

0: (Uninitialized) the send( ) method has not yet been invoked.
1: (Loading) the send( ) method has been invoked, request in progress.
2: (Loaded) the send( ) method has completed, entire response received.
3: (Interactive) the response is being parsed.
4: (Completed) the response has been parsed, is ready for harvesting.

0 - (未初始化)還沒有調(diào)用send()方法
1 - (載入)已調(diào)用send()方法,正在發(fā)送請求
2 - (載入完成)send()方法執(zhí)行完成,已經(jīng)接收到全部響應(yīng)內(nèi)容
3 - (交互)正在解析響應(yīng)內(nèi)容
4 - (完成)響應(yīng)內(nèi)容解析完成,可以在客戶端調(diào)用了

第五種 加載圖片

      <html>
<head>
<title>JavaScript圖片預(yù)加載代碼,顯示loading</title>

<style type="text/css">
	div{
		border:#aaaaaa 3px solid;
		width:200px;
		padding:2px;
		margin:2px 9px;
		font-size:12px;
		line-height:22px;
		color:#999999;
	}

	.ipt1{
		width:160px;
		font-size:12px;
		color:#1F6478;
		border:#999999 1px solid;
		margin-left:9px;
	}

	.ipt2{
		border:#999999 1px solid;
		margin-left:6px;color:#666666;
	}

	p{
		margin:0px;
		padding:0px;
		background-image:url(http://www.codefans.net/jscss/demoimg/loading.gif);
		background-position:center;
		background-repeat:no-repeat;
		width:200px;
		height:200px;
		text-align:center;
		font-size:12px;
		color:#999999;
		line-height:26px;
	}
</style>

<script language="javascript" type="text/javascript">
	function preloadimg(url,obj,ipt){
		var img = new Image();
		obj.innerHTML = "<p>Loading...</p>";
		img.onload = function(){
			obj.innerHTML = "";
			obj.style.width = String(img.width)+"px";
			ipt.style.width = String(img.width-40)+"px";
			obj.appendChild(img);
		};

		img.onerror = function(){
			obj.innerHTML="Loading Fail !"
		};

		img.src = url; //img.src 一定要寫在img.onload之后,否則在IE中會出現(xiàn)問題
	}

	function show(){
		var div = document.getElementsByTagName("div")[0];
		var input = document.getElementsByTagName("input");

		preloadimg("http://www.codefans.net/jscss/demoimg/wall9.jpg",div,input[0]);
		input[0].onclick = function(){this.value=""};
		input[1].onclick = function(){preloadimg(input[0].value,div,input[0]);}
	}
	window.onload = show;
</script>

</head>

<body>
<div></div><br />
<input type="text" value="將圖片地址粘貼在這里" class="ipt1"/><input type="button" value="開始加載" class="ipt2"/>
</body>
</html>
    
?
或者使用

      <script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="MinmyLazyload.js" type="text/javascript"></script>
<body>
<img original="http://justcoding.iteye.com/uploadfiles/20100424-2_20914.jpg">
<img original="http://justcoding.iteye.com/uploadfiles/20100423-1_85399.jpg">
<script type="text/javascript">$("img").lazyload({ placeholder: "img-loader.gif", effect:"fadeIn" });
</script>
</body> 
    
?
minimylazyload.js 在附件中找

第六種 本頁
?
    <style>
	#loading{font-size:12px;color:#FFFFFF;background:#FF0000;position:absolute;top:500px;left:500px; z-index:1002; padding:2px 10px 2px 10px}
</style>

<body>
	<div id="loading">頁面加載中…</div>
	 
	..........
	 
	<script type="text/javascript">
		document.write('<style>#loading{display:none;}</style>');
	</script>
</body>
</html>

  

jQuery 頁面載入進(jìn)度條 (必有一款適合你----綜合搜集版)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 草草在线播放 | 久久99视频 | 四虎成人国产精品视频 | 欧洲成人在线观看 | 亚洲欧美综合乱码精品成人网 | 亚洲国产天堂久久精品网 | 亚洲国产成人久久一区www | 久草在线视频免费 | 91精品国产闺蜜国产在线 | 9久re热视频这里只有精品 | 国产精品视频色拍拍 | www.免费视频 | 女人夜色黄网在线观看 | 日日摸天天摸狠狠摸视频 | 日日舔夜夜操 | 国产成人高清精品免费观看 | 国产精品麻豆久久久 | 国产极品粉嫩福利在线观看 | 久久九九 | 国产午夜影院 | 成 人国产在线观看高清不卡 | 欧美成人毛片免费视频 | 中文字幕高清免费不卡视频 | 国产精品久久久久久久久夜色 | 在线精品福利 | 羞羞视频网页 | 亚1洲二区三区四区免费 | 美日韩免费视频 | 福利影院在线播放 | 九九99热久久精品在线6手机 | 中文字幕曰韩一区二区不卡 | 久久网综合 | 免费久久精品国产片香蕉 | 99精品国产在现线免费 | 国产成人精品免费午夜 | 特级女人十八毛片a级 | 国产精品免费综合一区视频 | 日本一区二区三区精品 | 九七影院97影院理论片 | 91在线视频在线观看 | 国产操穴|