cuốn sách gpt4 ai đã làm

javascript - 移动浏览器中的 $(document).height() != $(window).height()

In lại Tác giả: Walker 123 更新时间:2023-11-28 07:59:26 28 4
mua khóa gpt4 Nike

这个问题之前曾被问过(Infinite Scroll on Mobile browsers),但没有得到回应。

我正在尝试实现无限滚动。

检查文档是否在底部,导致更多加载的函数是:

if ($(window).scrollTop() == $(document).height() - $(window).height())

这在我的计算机上运行良好,但不适用于移动设备 (iOS) 上的任何浏览器。

在我的页面的 iPhone 5s 上,$(document).height() 报告为 1055,$(window).height() 为 504。但即使在页面底部,$(window).scrollTop() 也最多为 507。因此 507 != 551 (1055-504)

我相信这可能与 $(window).height() 报告视口(viewport)的高度有关,这在移动设备上有所不同。

如有任何帮助,我们将不胜感激!

câu trả lời hay nhất

对我来说,这句神奇的话适用于移动和桌面 Chrome 浏览器:

$(document).height() - window.visualViewport.height

关于javascript - 移动浏览器中的 $(document).height() != $(window).height(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25613859/

28 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress