在select,focus或always(jQuery)上显示iPad键盘

时间:2011-01-02 14:51:47

标签: jquery ipad keyboard

我有一个使用jQuery的Web应用程序用TAB替换RETURN键,这样当我用户按下返回时,表单不会被提交,而是光标移动到下一个文本字段。

这适用于所有浏览器,但iPad上仅有1/2。在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);
    }
};

1 个答案:

答案 0 :(得分:2)

我认为,如果没有用户触摸文字输入元素并触发clickmouseupmousedown,就无法显示键盘。

这似乎是by design

  

根据设计,Mobile Safari中的一些focus()事件将被忽略。很多网站都会不必要地聚焦()并且提起键盘是缓慢/干扰的。

相关问题