详细介绍,请参考:flush 让页面分块,逐步呈现
假设有一个页面,一开始显示 cnblogs 的 logo 图标,3 秒钟后显示 csdn 的 logo 图标。
我根据上文介绍,用 asp.net 实现了上述功能。
ASP.NET 代码如下:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="flush让页面分块逐步呈现.aspx.cs" Inherits="Web_1.flush让页面分块逐步呈现" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///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>
