chi*_*cal 19 javascript pagination
我正在尝试确定何时滚动到页面底部(不使用任何JS库),但到目前为止,我对使用以下哪一项感到困惑.我见过的最有希望的是window.scrollY,但即使滚动到页面底部,它也永远不会匹配的值window.innerHeight.最好的方法是什么?
window.innerWidth
window.innerHeight
window.outerWidth
window.outerHeight
window.scrollX
window.scrollY
document.body.scrollWidth
document.body.scrollHeight
document.body.scrollTop
document.body.scrollLeft
document.body.offsetTop
document.body.offsetLeft
document.body.offsetWidth
document.body.offsetHeight
Run Code Online (Sandbox Code Playgroud)
Gab*_*oli 26
当window.innerHeight+ document.body.scrollTop大于或等于document.body.offsetHeight那么你就在底部
但由于IE存在这些属性的问题,您需要使用其他属性,例如
document.documentElement.scrollTop用于滚动和document.documentElement.clientHeight窗口高度
完整代码:http://jsbin.com/egegu3/6/edit
作为一个懒惰的人,我会将一个元素放在DIV的最底层,并在其上应用" 视图元素 "jQuery插件.(免责声明:我没有经验,但看起来不错.)
博客条目中的示例稍有不同:
$('#bottomDIV').bind('inview', function (event, visible) {
if (visible == true) {
// element is now visible in the viewport
highlightButtons(); // or whatever you want to do in the context
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17166 次 |
| 最近记录: |