简体   繁体   English

当滚动条距离窗口底部200px远时加载AJAX页面,窗口大小可能会有所不同

[英]load AJAX page when scrollbar is 200px far from bottom of the window where window size may vary

I have tried this condition so far. 到目前为止,我已经尝试过这种情况。

'if ($(window).scrollTop() == $(document).height() - $(window).height())'

so can anybody help me to get the solutuion .??? 所以有人可以帮助我获得解决方案吗???

$(window).on('scroll', function() {
    if (($(this).scrollTop() + $(this).height()) - $(document).outerHeight(true) > (-200)) {...}
});

FIDDLE 小提琴

Try this: 尝试这个:

$(function () {
    $(window).on('scroll', function () {
        if ($(window).scrollTop() + $(window).height() >= $(document).height() - 200) {
            //initate ajax here
        }
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM