最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - IOS disable the keyboard tab arrows - Stack Overflow

programmeradmin3浏览0评论

I need to disable the keyboard tab arrows on IOS using JavaScript or even an web based app meta tag if there is one.

I have tried a few options but have ran into issues when it es to select menus.

I also cannot revert all of the tabindex's to -1 because this damages tab-ability on a desktop and other devices.

Any help would be appreciated.

This is an excample of what I done for the fields jumping to readonly.

$(document).ready(function() {

  $('input, textarea, select').on('focus', function() {
    $('input, textarea').not(this).attr('readonly', 'readonly');
    $('select').not(this).attr("disabled", "disabled");
  });

  $('input, textarea, select').on('blur', function() {
    $('input, textarea').removeAttr("readonly");
    $('select').removeAttr("disabled");
  });

});

I need to disable the keyboard tab arrows on IOS using JavaScript or even an web based app meta tag if there is one.

I have tried a few options but have ran into issues when it es to select menus.

I also cannot revert all of the tabindex's to -1 because this damages tab-ability on a desktop and other devices.

Any help would be appreciated.

This is an excample of what I done for the fields jumping to readonly.

$(document).ready(function() {

  $('input, textarea, select').on('focus', function() {
    $('input, textarea').not(this).attr('readonly', 'readonly');
    $('select').not(this).attr("disabled", "disabled");
  });

  $('input, textarea, select').on('blur', function() {
    $('input, textarea').removeAttr("readonly");
    $('select').removeAttr("disabled");
  });

});

Share Improve this question edited Sep 23, 2016 at 19:04 pedrouan 12.9k3 gold badges59 silver badges75 bronze badges asked Sep 23, 2016 at 17:38 user4563161user4563161 2
  • Have you troubles with this in mobile safari? – pedrouan Commented Sep 23, 2016 at 17:50
  • @pedrouan Yes mate. – user4563161 Commented Sep 23, 2016 at 19:03
Add a ment  | 

2 Answers 2

Reset to default 9

I actually found a way to do this that works quite while.

What i'm doing is detecting IOS only devices and then disabling the tabbing to input fields.

I suppose I could go a step further and detect IOS and safari.

$(document).ready(function() {
  // Detect IOS
  if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {

    // Only active input fields in use
    $('input, textarea').on('focus', function() {
      $('input, textarea').not(this).attr("readonly", "readonly");
    });
    $('input, textarea').on('blur', function() {
      $('input, textarea').removeAttr("readonly");
    });

    // Disable tabing to select box's
    $('select').attr('tabindex', '-1');
  }
});

This is an issue that can't be solved by setting a html attribute, meta tag or listening to special events(there is no event for those arrows...).

The only option is to disable all other inputs in the form when a input is focused so that there is no input to tab to.

Instead of writing this code and reinventing the wheel, here's a link to a jquery module that already does this: https://github./ChrisWren/touch-input-nav

If you want a pure js solution, have a look at: https://github./ChrisWren/touch-input-nav/blob/master/touch-input-nav.js there isn't that much code that needs rewriting so that shouldn't be an issue.

发布评论

评论列表(0)

  1. 暂无评论