当phonegap页面加载时,如何专注于输入字段? [英] How can I focus on an input field when a phonegap page loads?
问题描述
当页面加载时,我想在PhoneGap应用程序中专注于文本输入。我试过MooTools版本 $('entry')。focus();
和 document.getElementById('entry')。focus / code>当DOM准备好了。
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.
当在正常的网络浏览器中查看HTML页面时,这样工作正常,但在运行PhoneGap的iPhone模拟器中,它不工作。
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.
有没有办法专注于强制虚拟键盘出现的iPhone的表单字段?
Is there a way to focus on a form field for iPhones that forces the virtual keyboard to appear?
推荐答案
从iOS 6开始,UIWebView类有一个名为keyboardDisplayRequiresUserAction的属性。如果你想以编程方式聚焦文本表单元素,通过你的phonegap config.xml设置为false:
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" />
默认值为true。
更多详情: http://community.phonegap.com/nitobi/topics/calling_focus
这篇关于当phonegap页面加载时,如何专注于输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!