结合上一篇中的js函数,简单仿照企鹅微博上当滚动条接近网页底部时,微博内容的加载。
本文地址:http://www.cnblogs.com/vnii/archive/2012/02/08/2342884.html
代码:
//整个网页滚动时
webPage.addEvent(window, "scroll", function () {
var rb = webPage.rightBottom();//当前页面区域右下角距网页左上角的位置差,见上一篇
if (rb.y + 50 >= webPage.size().height) {
document.body.appendChild(webPage.$div({ "width": 180, "height": 100, "color": "#970568", "x": 10, "y": 10, "z": 999, "styleText": "border:1px solid" }));
}
});
//某个div内
var tObj=document.getElementById("t");
webPage.addEvent(tObj, "scroll", function () {
var r = parseInt(tObj.scrollTop) + parseInt(tObj.style.height);
if (r + 20 >= tObj.scrollHeight) {
tObj.appendChild(webPage.$div({ "width": 10, "height": 10, "x": 10, "y": 10, "z": 999, styleText: "border:1px solid" }));
}
});