【问题标题】:Show iPad keyboard on select, focus or always (jQuery)在选择、焦点或始终显示 iPad 键盘 (jQuery)
【发布时间】:2011-06-02 12:11:26
【问题描述】:

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

这适用于所有浏览器,但只有 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);
    }
};

【问题讨论】:

    标签: jquery ipad keyboard


    【解决方案1】:

    我认为,如果用户不触摸文本输入元素并触发 clickmouseupmousedown,则无法显示键盘。

    这似乎是by design

    根据设计,Mobile Safari 中的一些 focus() 事件会被忽略。很多网站会不必要地做 focus() 并且调出键盘很慢/很麻烦。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-18
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多