[英]How to scroll to the bottom of the page in a mobile device
我正在尝试在收到或发送新消息时向下滚动到页面底部,我已经完成了所有设置,并且在我的笔记本电脑上运行良好,但是当我尝试在移动设备上访问我的网站时,滚动事件不是在职的。
好吧,我已经使用了 jQuery 滚动和纯 javascript 滚动,但它们都没有在移动设备上工作
以下是我在互联网上找到的所有功能:
//first method
window.scrollTo(0,document.body.scrollHeight);
//second method
$("html,body").animate({
scrollTop: $(document).height()
}, "slow");
//third method
$('my-messages-container').animate({ scrollTop : $(document).height()+1000000 });
好吧,当我使用开发人员工具移动模拟时,代码运行良好。 但是当我在真正的移动设备上尝试时,它不起作用。
elementAtBottomOfPage.scrollIntoView()
最终在 iOS 上为我工作的是什么。
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
如上所述: jQuery Scroll To bottom of the page
$("html, body").animate({scrollTop: $(document).height()-$(window).height()});
会让你到页面的底部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.