/************************瀑布流**********************************/
/*滚动条在Y轴上的滚动距离*/
function ScrollTop()
{
var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
if (document.body)
{
bodyScrollTop = document.body.scrollTop;
}
if (document.documentElement)
{
documentScrollTop = document.documentElement.scrollTop;
}
scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
return scrollTop;
}
/*文档的总高度*/
function ScrollHeight()
{
var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
if (document.body)
{
bodyScrollHeight = document.body.scrollHeight;
}
if (document.documentElement)
{
documentScrollHeight = document.documentElement.scrollHeight;
}
scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
return scrollHeight;
}
/*浏览器视口的高度*/
function WindowHeight()
{
var windowHeight = 0;
if (document.compatMode == "CSS1Compat")
{
windowHeight = document.documentElement.clientHeight;
} else
{
windowHeight = document.body.clientHeight;
}
return windowHeight;
}
window.onscroll = function ()
{
if (ScrollTop() + WindowHeight() + 5 >= ScrollHeight())
{
More();
}
};
/************************End**********************************/
//调用方法
P_intPageIndex = 1;
P_intPageSize = 20;
P_intRecordCount = 0;
function More()
{
var SumIndex = (P_intRecordCount % P_intPageSize) == 0 ? parseInt(P_intRecordCount / P_intPageSize) : parseInt(P_intRecordCount / P_intPageSize) + 1;
if (SumIndex > P_intPageIndex)
{
P_intPageIndex++;
ScrollList();
}
}
//第一次调用的函数与第二调用的函数是有区别的。在ScrollList中需加上如下js,
//strSearch 为生成好的html,需拼接在原来数据的后面
//sessionStorage是html5中类似于session,cookie的东西,能存储大量的数据
//这里分别定义sessionStorage.data1记录之前的数据 ,sessionStorage.PageIndex1记录之前的页数。
if (strSearch != "")
{
var data = $("#List").html();
strSearch = data + strSearch;
$("#List").html(strSearch);
sessionStorage.data1 = strSearch;
sessionStorage.PageIndex1 = P_intPageIndex;
}