最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp.net 頁面逐步呈現(xiàn)的方法總結(jié)

 更新時間:2010年06月23日 12:26:34   作者:  
分塊編碼 ( chunked encoding )就是讓 response 分塊編碼進(jìn)行傳輸。response 分塊編碼,可以先傳輸一部分不需要處理的 html 代碼到客戶端,等其他耗時代碼執(zhí)行完畢后再傳輸另外的 html 代碼。
詳細(xì)介紹,請參考:flush 讓頁面分塊,逐步呈現(xiàn)
假設(shè)有一個頁面,一開始顯示 cnblogs 的 logo 圖標(biāo),3 秒鐘后顯示 csdn 的 logo 圖標(biāo)。

我根據(jù)上文介紹,用 asp.net 實(shí)現(xiàn)了上述功能。
ASP.NET 代碼如下:
復(fù)制代碼 代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="flush讓頁面分塊逐步呈現(xiàn).aspx.cs" Inherits="Web_1.flush讓頁面分塊逐步呈現(xià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 runat="server">
<title>flush讓頁面分塊逐步呈現(xiàn)</title>
</head>
<body>
<div id="head" style="border:1px solid #ccc;">
cnblogs logo <img src="http://images.cnblogs.com/logo_small.gif" alt=""/>
</div>
<%
// flush分塊輸出
Response.BufferOutput = false;
Response.Flush();
// Response.Output.Flush();
%>
<br /> 3 秒后加載下面內(nèi)容...
<div id="content" style="border:1px solid blue;">
<%
// 睡眠3秒
System.Threading.Thread.Sleep(3000);
%>
csdn logo <img src="http://csdnimg.cn/www/images/csdnindex_piclogo.gif" alt=""/>
</div>
</body>
</html>


如果想實(shí)現(xiàn) tudou.com 首頁圖片延遲加載的效果,則可以使用 jquery 輕松實(shí)現(xiàn)。
詳細(xì)介紹,請參考:名站技術(shù)分析 - 淺談 tudou.com 首頁圖片延遲加載的效果

JQuery 代碼如下:
復(fù)制代碼 代碼如下:

<!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" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
一開始能看到的圖片:
<img src="http://at-img4.tdimg.com/board/2010/5/tylc-115X55.jpg"/>
<div id="lazyBox" style="margin-top:100px;">
一開始看不到下面的圖片,滾動鼠標(biāo)后可以看見:
<img width="120" height="90" style="border:1px solid blue;" class="lazyImg" alt="http://i01.img.tudou.com/data/imgs/i/051/871/396/m20.jpg" src="http://css.tudouui.com/skin/__g/img/sprite.gif" coords="_DBA"/>
</div>
<div style="height:1000px;"></div>
<script type="text/javascript">
var hasShow = false;
$(window).bind("scroll",function(){
if(hasShow==true){
$(window).unbind("scroll");
return;
}
var t = $(document).scrollTop();
if(t>50){
// 滾動高度超過50,加載圖片
hasShow = true;
$("#lazyBox .lazyImg").each(function(){
$(this).attr("src",$(this).attr("alt"));
});
}
});
</script>
</body>
</html>

相關(guān)文章

最新評論

宁武县| 林芝县| 广丰县| 常熟市| 伊通| 徐闻县| 澄城县| 黎城县| 抚松县| 应城市| 九龙县| 浏阳市| 镇宁| 时尚| 乌鲁木齐县| 武鸣县| 南岸区| 石台县| 十堰市| 铁岭市| 南皮县| 潍坊市| 盐池县| 德保县| 宁德市| 景宁| 遵义县| 繁昌县| 巴彦县| 深泽县| 石柱| 景德镇市| 黄大仙区| 遵化市| 郸城县| 湘潭市| 宁强县| 漠河县| 古田县| 绥江县| 通道|