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

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

问题描述

我有一个网络应用程序。我试图禁用/防止当您关注不同的表单输入时发生的滚动(例如,当您通过表单中的输入元素前进时发生的滚动)。

我已经停用了滚动功能:

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

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

有谁知道如何做到这一点?

$ b code> .focus()我发现在UIWebView中,document.body有时也会移动。所以我使用:

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


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).

I've already disabled scrolling with this:

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

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.

Does anyone know how to do this?

解决方案

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天全站免登陆