从 JavaScript 手动触发 iPhone/iPad/iPod 键盘 [英] Manually triggering the iPhone/iPad/iPod keyboard from JavaScript
本文介绍了从 JavaScript 手动触发 iPhone/iPad/iPod 键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用简单的 DIV 和捕获事件开发 HTML 代码编辑器.当我在 iPad 上使用它时,键盘永远不会弹出,因为我在技术上不在可编辑字段中.
有没有办法以编程方式告诉 iPad 我需要一个键盘?
解决方案
如果您的代码是通过用户操作启动的某些内容来执行的,那么它会起作用.
例如;
这有效(弹出键盘):
click
这不起作用(输入有边框但没有键盘弹出):
<脚本>window.onload = 函数(){$("#foo").focus();}
I am developing an HTML code editor using simple DIV's and capturing events. When I use this on the iPad the keyboard never pops up since i'm not technically in an editable field.
Is there a way to programatically tell the iPad that I need a keybaord?
解决方案
If your code is executed via something that was initiated via a user action then it will work.
E.g;
this works (pops keyboard):
<input type='text' id='foo'><div onclick='$("#foo").focus();'>click</div>
this doesn't work (input gets a border but no keyboard pop):
<input type='text' id='foo'>
<script>
window.onload = function() {
$("#foo").focus();
}
</script>
这篇关于从 JavaScript 手动触发 iPhone/iPad/iPod 键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文