Javascript 当页面缩放(调整大小)时,如何检测滚动到底部?

Javascript 当页面缩放(调整大小)时,如何检测滚动到底部?,javascript,scroll,scale,detect,Javascript,Scroll,Scale,Detect,我检测到滚动到底部以加载新页面此处显示消息: window.onscroll = function(ev) { if ((window.innerHeight + window.scrollY) >= document.height) { alert("scrolled to bottom"); } }; 如果现在在我的android 2.2上缩放页面内容(例如图像),则会触发该功能,而不会实际看到页面底部 我尝试使用document.height以外的

我检测到滚动到底部以加载新页面此处显示消息:

window.onscroll = function(ev) {
    if ((window.innerHeight + window.scrollY) >= document.height) { 
        alert("scrolled to bottom");
    }
};
如果现在在我的android 2.2上缩放页面内容(例如图像),则会触发该功能,而不会实际看到页面底部

我尝试使用document.height以外的其他属性,希望它们在缩放时会改变,但它们不会:

alert("1="+document.documentElement.clientHeight+
      " 2="+window.innerHeight+
      " 3="+window.outerHeight+
      " 4="+document.body.clientHeight+
      " 5="+document.body.offsetHeight+
      " 6="+document.body.scrollHeight+
      " 7="+document.documentElement.clientHeight+
      " 8="+document.documentElement.offsetHeight+
      " 9="+document.documentElement.scrollHeight);
显示相同的数字,无论页面在手机上缩放了多少

我想,我会放置一个必须通过的div,但是div的位置保持不变,与缩放无关…:

var div = document.getElementById ("mydiv");
var rect = div.getBoundingClientRect ();
x = rect.left;
y = rect.top;
w = rect.right - rect.left;
h = rect.bottom - rect.top;
alert ("left: " + x + " top: " + y + " width: " + w + " height: " + h);

当用户确实已滚动到底部时,我如何检测,例如,已看到完整图像并进一步滚动…?

当页面滚动到底部时,我想加载更多内容时,我遇到了相同的问题

我通过在最后加载的内容后的页面底部添加一个空元素来解决此问题,并检查它是否可见或通过以下命令:

if($("#LoadIndicator")[0].getBoundingClientRect().bottom < window.innerHeight + 50)
{
    //Processing...
}
LoadIndicator是元素的ID,我认为50像素是到页面底部加载下一个内容的距离

希望能有所帮助