更改焦点表单元素 ipad web 应用程序时禁用滚动 [英] Disable scrolling when changing focus form elements ipad web app

查看:25
本文介绍了更改焦点表单元素 ipad web 应用程序时禁用滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络应用.我试图禁用/防止在您关注不同表单输入时发生的滚动(即在您浏览表单中的输入元素时发生的滚动).

I have a web app. I'm trying to disable/prevent the scrolling that occurs when you focus on different form inputs (i.e. the scrolling that occurs as you advance through input elements in a form).

我已经禁用了滚动:

 <script type="text/javascript">
     $(document).ready(function() {
         document.ontouchmove = function(e){
              e.preventDefault();
              }
     });
 </script>

要添加更多信息 - 我的页面包含一些幻灯片".每个都是 768x1024 并且它们在页面上堆叠"(即页面是 768x3072 [1024*3=3072]),当您单击链接时,我正在使用 scrollTo jquery 插件滚动到下一个幻灯片"和 .focus() 在输入元素上.

To add a little more info - I have a few "slides" that my page consists of. Each are 768x1024 and they are "stacked" on the page (i.e. the page is 768x3072 [1024*3=3072]) and when you click a link I'm using scrollTo jquery plugin to scroll to the next "slide" and .focus() on an input element.

有人知道怎么做吗?

推荐答案

我发现在 UIWebView 中,document.body 有时也会被移动.所以我使用:

I've found that in UIWebView, document.body is also sometimes moved. So I use:

    input.onfocus = function () {
        window.scrollTo(0, 0);
        document.body.scrollTop = 0;
    }

这篇关于更改焦点表单元素 ipad web 应用程序时禁用滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆