Javascript Jquery检查用户是否在底部不工作

Javascript Jquery检查用户是否在底部不工作,javascript,jquery,Javascript,Jquery,我有一个jquery代码,可以检查用户是否点击页面底部,但它似乎工作不正常,我无法找出问题所在 <script> $(document).ready(function(){ var load = 0; $(window).scroll(function(){ if($(window).scrollTop() == $(document).height() - $(window).height(

我有一个jquery代码,可以检查用户是否点击页面底部,但它似乎工作不正常,我无法找出问题所在

  <script>
        $(document).ready(function(){
          var load = 0;
            $(window).scroll(function(){
              if($(window).scrollTop() == $(document).height() - $(window).height()){
                alert("test");
              }
            });
        });
      </script>

$(文档).ready(函数(){
无功负荷=0;
$(窗口)。滚动(函数(){
if($(窗口).scrollTop()==$(文档).height()-$(窗口).height()){
警报(“测试”);
}
});
});
在代码中键入错误…如果($(window).scollTop()


$(文档).ready(函数(){
无功负荷=0;
$(窗口)。滚动(函数(){
if($(窗口).scrollTop()==$(文档).height()-$(窗口).height()){
警报(“测试”);
}
});
});
另外,您是否有一个固定导航栏,它可能会偏离偏移量?

当您执行
$(document).height()-$(window.height()
时,我当前的浏览器firefox中至少会有一些细微的差异

请尝试以下代码

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("test");
   }
});
适用于所有浏览器

谢谢,
这只是一个输入错误,
scollTop
应该是
scrollTop
。它似乎仍然不起作用……我有一个“include”(“menubar.php”)在我的文件中,我询问的原因是,如果它是固定的,则主体上会有填充,因此必须将其添加到计算中以确定滚动位置。如果我有50px填充或其他内容,我该如何计算它?不知道-但请尝试…var offset=50;…$(document).height()-($(窗口).height()+offset)我相信你一定能研究出正确的术语/逻辑。
$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("test");
   }
});