我希望当用户滚动到页面底部时实现内容加载。
我有个问题。它在桌面浏览器上运行得很好,但在移动设备上就不行。我已经实现了一个肮脏的修复来使它在iPhone上工作,但并不是最优的,因为它不能在其他大小的移动设备上工作。
我的网站是www.cristianrgreco.com,向下滚动查看实际效果
问题是在移动设备上添加滚动和高度并不等于高度,而在桌面浏览器上却是这样。
有没有一种方法可以检测移动浏览器?
提前谢谢。
下面是当前正在使用的代码:
$(document).ready(function () {
$(".main").hide().filter(":lt(3)").show();
if ($(document).height() == $(window).height()) {
// Populate screen with content
}
else if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {
window.onscroll = function () {
if ($(document).height() - $(window).scrollTop() <= 1278) {
// At the moment only works on iPhone
}
}
}
else {
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() >= $(document).height()) {
// Works perfect for desktop browsers
}
})
}
})
https://stackoverflow.com/questions/8220267
复制相似问题