如何防止移动 Safari 上文本区域中的页面滚动

发布于 2024-09-25 02:17:14 字数 330 浏览 0 评论 0原文

我正在尝试为有趣的移动游猎制作一个小记事本应用程序,但到目前为止它似乎还没有成功。我想防止页面滚动,这样它就没有橡皮筋,感觉像一个网络应用程序,但为了做到这一点,我正在使用:

document.ontouchmove = function(e){
    alert("calling prevent default");
    e.preventDefault(); 
}

这非常有效,除了在文本区域中,它看起来像 ontouchmove 永远不会被触发,所以页面滚动仍然会发生。有没有人知道如何更改苹果在文本区域中的默认功能,或者找到没有苹果默认功能的文本区域的替代方案?

I am trying to make a little note pad app for mobile safari for funzies but so far it doesn't seem to be working out. I want to prevent page scrolling so it doesn't have the rubberband and feel like a webapp but to do this I am using:

document.ontouchmove = function(e){
    alert("calling prevent default");
    e.preventDefault(); 
}

This works great except for in textarea where it looks like ontouchmove never gets fired so page scrolling still happens. Has anyone figured out how to change apple's default functionality in the text area or figured out an alternative to text area that doesn't have apple's default functionality?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥醉 2024-10-02 02:17:14

目前看来还没有好的解决办法。我发现一个项目也在努力解决这个问题,人们已经通过文本字段上的隐藏跨度发挥了创意,但这对我来说仍然是一个很大的问题。

http://code.google.com/p/iscroll-js /issues/detail?id=24

我想这只是移动 Safari 的限制,因为目前我似乎没有找到好的解决方案。

There does not appear to be a good solution at this time. I found a project that is struggling with this problem as well and folks have gotten creative with hidden spans over text fields but that is still pretty buggy for me.

http://code.google.com/p/iscroll-js/issues/detail?id=24

I guess this is just a limitation to mobile safari as there doesn't appear to be a good solution that I can find at this time.

铁憨憨 2024-10-02 02:17:14

我在某处读到,将内容放入带有 "overflow:hidden" 的 <div> 中并设置 div 的高度应该可以防止滚动。请告诉我们是否有效。

I read somewhere that putting your content in a <div> with "overflow:hidden" and setting the height of the div should prevent scrolling. Please tell us if it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文