$(窗口).scroll(功能()不工作在Firefox? [英] $(window).scroll(function() not working on firefox?
问题描述
为了加载页面Facebook或Twitter在他们的网站,滚动下来,我已经试过这个与jQuery:
$(window).scroll(function(){
if($(window).scrollTop()== $(document).height() - $(window).height()){
//做某事
}
}
我有麻烦如果我在IF中使用alert('xx'),Firefox会崩溃,我必须重新启动它。
我使用Firefox的Mac版本,但我想这不是一个重要的事实。
任何人都知道这里发生了什么?
谢谢。
我有同样的问题:在调试后,我发现$(document).height() - $(window).height()和$(window).scrollTop()在firefox之间有1 px的区别但不是($(window).scrollTop()+ 1> = $(document))。 .height() - $(window).height()){
//在这里做某事
}
In order to load pages as facebook or twitter does at their sites, scrolling down, i have tried this with jquery:
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
//do something
}
}
And i am having troubles with Firefox. Not with Chrome and either with Safari (IE not tested yet).
If i use an "alert('xx')" inside the IF, Firefox crashes and i have to restart it.
I am using the Mac version of Firefox but i guess that's not an important fact.
Anyone have any idea about what's happening here? Thanks.
I have the same problem: it works in chrome but not in firefox and IE. After debugging i found that there is a 1 px difference between $(document).height() - $(window).height() and $(window).scrollTop() in firefox but not in chrome. My working solution here:
if ($(window).scrollTop() + 1 >= $(document).height() - $(window).height()){
//do something here
}
这篇关于$(窗口).scroll(功能()不工作在Firefox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!