加载 phonegap 页面时,如何专注于输入字段? [英] How can I focus on an input field when a phonegap page loads?

查看:27
本文介绍了加载 phonegap 页面时,如何专注于输入字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在页面加载时关注 PhoneGap 应用程序中的文本输入.当 DOM 准备好时,我已经尝试过 MooTools 版本 $('entry').focus();document.getElementById('entry').focus() .

当在普通 Web 浏览器中查看 HTML 页面时,这可以正常工作,但在运行 PhoneGap 的 iPhone 模拟器中,它不起作用.

有没有办法专注于强制显示虚拟键盘的 iPhone 表单域?

解决方案

从 iOS 6 开始,UIWebView 类有一个名为keyboardDisplayRequiresUserAction"的属性.如果您想以编程方式聚焦文本表单元素,请通过您的 phonegap config.xml 将其设置为 false:

默认值为 true.

更多信息:http://community.phonegap.com/nitobi/topics/calling_focus

I would like to focus on a text input in a PhoneGap application when the page loads. I have tried the MooTools version $('entry').focus(); and document.getElementById('entry').focus() when the DOM is ready.

This works fine when the HTML page is viewed in a normal web browser, but in the iPhone simulator running PhoneGap, it doesn't work.

Is there a way to focus on a form field for iPhones that forces the virtual keyboard to appear?

解决方案

As of iOS 6, the UIWebView class has a property called "keyboardDisplayRequiresUserAction". If you want to programmatically focus text form elements, set this to false via your phonegap config.xml:

<preference name="KeyboardDisplayRequiresUserAction" value="false" />

The default value is true.

More here: http://community.phonegap.com/nitobi/topics/calling_focus

这篇关于加载 phonegap 页面时,如何专注于输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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