我有一个网络应用程序,它使用 jQuery 将 RETURN 键替换为 TAB,这样当我用户按下 Return 键时,表单不会提交,而是光标会移动到下一个文本字段。
这适用于所有浏览器,但只有 1/2 适用于 iPad。在 iPad 上,下一个字段会突出显示,但键盘会被隐藏。如何保持键盘可见或以某种方式强制它?
这是我的代码(感谢 http://thinksimply.com/blog/jquery-enter-tab ):
function checkForEnter (event) {
if (event.keyCode == 13) {
currentBoxNumber = textboxes.index(this);
if (textboxes[currentBoxNumber + 1] != null) {
nextBox = textboxes[currentBoxNumber + 1]
nextBox.focus();
nextBox.select();
event.preventDefault();
return false;
}
}
}
Drupal.behaviors.formFields = function(context) {
$('input[type="text"]').focus(function() { $(this).removeClass("idleField").addClass("focusField"); });
$('input[type="text"]').blur(function() { $(this).removeClass("focusField").addClass("idleField"); });
// replaces the enter/return key function with tab
textboxes = $("input.form-text");
if ($.browser.mozilla) {
$(textboxes).keypress (checkForEnter);
} else {
$(textboxes).keydown (checkForEnter);
}
};
最佳答案
我相信,如果用户不触摸文本输入元素并触发点击
、mouseup
或mousedown
,就不可能显示键盘。
这似乎是by design :
By design, some focus() events in Mobile Safari are ignored. A lot of sites would do focus() unnecessarily and bringing up the keyboard is slow/intrusive.
关于jquery - 选择、聚焦或始终显示 iPad 键盘 (jQuery),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4578878/