防止iDevice上的弹性滚动

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了防止iDevice上的弹性滚动相关的知识,希望对你有一定的参考价值。

If you a flick a web app past the bottom or top of the page, the page itself gets elastically tugged away from the URL bar or the button bar (or the bottom/top of the screen if it's in full-screen mode).

This behavior is another giveaway that your app isn't native, and it's rarely the behavior you want in a native app.

To stop this behavior, capture touchmove events on the document in javascript and cancel them. You can do this by adding a handler to the body tag, and invoking the preventDefault method on the event object:
  1. <script>
  2. function BlockMove(event) {
  3. // Tell Safari not to move the window.
  4. event.preventDefault() ;
  5. }
  6. </script>
  7.  
  8. <body ontouchmove="BlockMove(event);" >
  9. ...
  10. </body>

以上是关于防止iDevice上的弹性滚动的主要内容,如果未能解决你的问题,请参考以下文章

阻止IOS上的弹性滚动

如何关闭 iPad 上的橡胶/弹性滚动效果?

大于动态宽度父项时,弹性项目上的滚动条

防止伪元素触发滚动

如何在滚动视图中设置谷歌地图片段

加载数据后如何防止滚动视图滚动到网络视图?