javascript ios7 使用键盘 html 时 webview 焦点的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19110144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 14:23:04  来源:igfitidea点击:

ios7 issues with webview focus when using keyboard html

javascripthtmlextjswebviewios7

提问by ItzikEdar

Sencha - I have a webapp with a registration form that works correctly on Safari. However, for some reason when adding the page to home screen (using ios webview) this issue appears:

Sencha - 我有一个带有注册表的 web 应用程序,可以在 Safari 上正常工作。但是,由于某种原因,将页面添加到主屏幕(使用 ios webview)时会出现此问题:

When I click on a text field the keyboard is not zooming to the specific field that was selected. In order to start writing to that text field, I need to press again on the text field.

当我单击文本字段时,键盘不会缩放到选定的特定字段。为了开始写入该文本字段,我需要再次按下该文本字段。

I am using sencha.

我正在使用煎茶。

回答by J. Furr

I found the solution for iOS 7. Use the following meta tag in your HTML pages:

我找到了适用于 iOS 7 的解决方案。在您的 HTML 页面中使用以下元标记:

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />

回答by George

I faced the same issue. In my case i am using jquery mobile and to solve this issue i added the attribute "autofocus" to the input field.
This seems to simulate a first tap on the field whereas the tap by the user opens the keyboard and he will be able to write to the field.
Hope this helps.

我遇到了同样的问题。就我而言,我使用的是 jquery mobile,为了解决这个问题,我在输入字段中添加了属性“ autofocus”。
这似乎模拟了对字段的第一次敲击,而用户的敲击打开了键盘,他将能够在该字段上写字。
希望这可以帮助。