iPad的HTML焦点 [英] iPad HTML Focus
问题描述
我在iPad上关注文本字段时遇到了问题。我在哪里使用:
pre $ $ $ $ c $ $(document).bind(click,function(event){
alert( 'click');
focusTextArea();
});
将焦点设置到文本区域,并出现键盘。但是,使用touchend调用时, 有人知道为什么会出现这种情况,我怎么能够得到这个工作? Adam 遗憾的是,使用iPad无法实现专注。将焦点放在所需字段的唯一方法是当用户点击所需字段。 更新2015-01-08: ... I have an issue with focusing a text field on the iPad. Where I use: The focus is set to the text area, and a keyboard appears. However when called with touchend, Does anybody know why this occurs, and how I might be able to get this to work? TIA, Adam Unfortunately, focusing is not possible with the iPad. The only way the focus will be placed in the desired field is when the user 'clicks' on the desired field. Update 2015-01-08: As explained in this answer by Matt: ...
iOS will only allow focus to be triggered on other elements, from
within a function, if the first function in the call stack was
triggered by a non-programmatic event. In your case, the call to
setTimeout starts a new call stack, and the security mechanism kicks
in to prevent you from setting focus on the input.
这篇关于iPad的HTML焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! focusTextArea
函数是: b $('#textArea')。focus();
}
TIA,
如果调用堆栈中的第一个函数是由非编程事件触发的
,则iOS仅允许在函数内的
的其他元素上触发焦点。在你的情况下,对
setTimeout的调用会启动一个新的调用堆栈,并且安全机制会触发
以阻止您将注意力集中在输入上。
$(document).bind("click",function(event) {
alert('click');
focusTextArea();
});
focusTextArea
is not called and the keyboard is not made visible. My focusTextArea
function is:function focusTextArea() {
$('#textArea').focus();
}