Firefox中的jQuery(window).scrollTop()问题?

时间:2014-06-26 00:17:16

标签: jquery firefox

当您向下滚过页面上的某个点时,我有以下代码用于显示隐藏的页脚。

jQuery(document).scroll(function(){
    if(jQuery(window).scrollTop() >= jQuery('.foot').offset().top + jQuery('.foot').height() - window.innerHeight) {
        // Add class here
    } else {
        // Remove class here
});

这在Chrome和IE中运行良好。但是在Firefox中不起作用。我把问题缩小到jQuery(窗口).scrollTop()。我创建了这个测试http://jsfiddle.net/captainmorgan/cVsRE/1/ 在Chrome中打开并使用鼠标滚轮向下滚动。我得到100.当我在Firefox中做同样的事情我得到114,但Firefox继续显示多个消息框,并且数量不断减少。 有谁知道为什么Firefox会这样做?

1 个答案:

答案 0 :(得分:0)

尝试:

jQuery(window).scroll(function(event) {
    var NextScroll = jQuery(this).scrollTop();
    if(NextScroll > (jQuery('.foot').offset().top + jQuery('.foot').height() - window.innerHeight)) {
         //action
    }

});
相关问题