OGeek|极客世界-中国程序员成长平台

标题: html - 当用户输入任何数据时如何防止ipad滚动 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:56
标题: html - 当用户输入任何数据时如何防止ipad滚动

当用户在 ipad 上输入数据时,有什么方法可以阻止这种滚动,我尝试了不同的方法但不起作用。

有什么办法可以阻止这种滚动。

这是我的代码

             <html lang = "en">
            <head>
            <title>formDemo.html</title>
            <meta charset = "UTF-8" />
            <script>
            $(document).ready(function() {  
                $(document).bind('touchmove', false);


          });

         </script>

         </head>
         <body>
        <h1>Form Demo</h1>
        <form>
       <label for="name">Text Input:</label>
       <input type="text"   name="name" id="inputtext"  onFocus="window.scrollTo(0, 0); value="" style="margin:400px 0 0 0;" />
       </form>
       </body>
       </html>



Best Answer-推荐答案


您的问题几乎得到解答here .您只需将您的逻辑与:

$(document).bind('touchmove', false); // or true, depends you want to disable / enable

关于html - 当用户输入任何数据时如何防止ipad滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17208546/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4