how do you prevent page scroll in textarea on mobile safari

你说的曾经没有我的故事 提交于 2019-12-12 13:13:59

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3795171/how-do-you-prevent-page-scroll-in-textarea-on-mobile-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!