正常的上拉触底自动加载代码:
$(window).scroll(function(){
var bottomsubmit =
(
′
.
m
o
r
e
c
a
s
e
′
)
.
o
f
f
s
e
t
(
)
.
t
o
p
−
('.morecase').offset().top-
(′.morecase′).offset().top−(window).height();
var nowtop = KaTeX parse error: Expected '}', got 'EOF' at end of input: …page>allpages){(’.morecase’).hide();return;}
state=false;
setTimeout(“mtonextpage()”,500);
}
}
});
当滚动条到底部时,才触发事件,我这样就可以加载我所需要的内容了,因为
(
d
o
c
u
m
e
n
t
)
.
s
c
r
o
l
l
T
o
p
(
)
>
=
(document).scrollTop()>=
(document).scrollTop()>=(document).height()-$(window).height()的意思是当滚动条高度大于窗口高度时-文档高度时,就触发该事件。
但后面出现错误的情况是:无论滚动条怎么动都会触发这个事件
后面打印出这两个值:发现这个$(document).height() 和 $(window).height() 这两个值在 google 和 firefox里的值竟然是一样的,在ie中却又不同,也就是不管滚动条怎么动,这个判断条件始终成立,所以出现了ie上没事,其他浏览器出现不正确的情况。
解决办法:
如果你和我一样都是改了这个才出了问题,那么就是这个原因了
我是改了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
改成了
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
就出错了。
最后改回来,这个问题就解决了
也就是$(window).height()的值正常了,真是坑爹的问题