我觉得这个问题的答案会非常简单,但它占用了我很多时间,而且我看不到解决方案。我正在制作一个简单的无限滚动功能,并且需要脚本在加载更多内容后识别窗口的新高度。该值始终与首次加载时间相同。我的最新代码基于 another answer here ,但仍然不起作用。想法?
var scrollFunction = function(){
var myTop = jQuery(window).scrollTop();
var myHeight = jQuery(window).height();
if (myTop >= myHeight){
$(window).unbind("scroll");
jQuery.ajax({
type: 'POST',
url: '/ping/thumbs.php',
data: 'foo=bar',
success: function(data){
$(".thumbnails").append(data);
$(window).scroll(scrollFunction);
},
dataType: 'html'
});
};
};
$(window).scroll(scrollFunction);
最佳答案
窗口的高度是浏览器窗口的大小。您需要 body
的高度。 window
高度仅在浏览器调整大小时改变。
关于jquery - jQuery AJAX 之后获取新的窗口高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12207518/