gpt4 book ai didi

jquery - jQuery AJAX 之后获取新的窗口高度

转载 作者:行者123 更新时间:2023-12-01 06:37:01 26 4
gpt4 key购买 nike

我觉得这个问题的答案会非常简单,但它占用了我很多时间,而且我看不到解决方案。我正在制作一个简单的无限滚动功能,并且需要脚本在加载更多内容后识别窗口的新高度。该值始终与首次加载时间相同。我的最新代码基于 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com