简体   繁体   English

你怎么在移动safari上阻止textarea中的页面滚动

[英]how do you prevent page scroll in textarea on mobile safari

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: 我想阻止页面滚动,所以它没有橡皮筋,感觉像一个webapp但是这样做我正在使用:

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. 这很有效,除了在textarea中看起来像ontouchmove永远不会被解雇所以页面滚动仍然发生。 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? 有没有人想出如何在文本区域中更改苹果的默认功能,或想出一个没有苹果默认功能的文本区域的替代品?

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 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. 我想这只是对移动游猎的限制,因为目前我找不到一个好的解决方案。

I read somewhere that putting your content in a < div> with "overflow:hidden" and setting the height of the div should prevent scrolling. 我在某处读到了将您的内容放在带有"overflow:hidden"的< div> ,并设置div的高度应该可以防止滚动。 Please tell us if it works. 请告诉我们它是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM