是否有解决 Safari/Opera 无法通过超链接选项卡的错误的解决方法?

发布于 2024-08-22 06:22:40 字数 656 浏览 2 评论 0原文

在 IE、Firefox、Chrome 和我使用过的大多数基于 Windows 的界面中,Tab 键可用于从一个表单字段或超链接导航到下一个表单字段或超链接 (例如“可操作”项目)(注意:我尚未在其他操作系统上进行测试

但是,Safari 和 Opera 在切换时跳过网页中的所有超链接。恕我直言,这是一个可用性错误,但我离题了。

是否有解决方法/黑客可以让 Safari 和/或 Opera 浏览这些链接?

我注意到,如果设置了例如 tabindex="0" ,Opera 将接受 tabindex 属性,从而在页面上的 DOM 流中维护链接“索引”。 ..但 Safari 不想接受这一点。

对于那些感兴趣的人来说,这段 jQuery 将使所有超链接都可选项卡式显示。

//Make links 'tab-able' in Opera
$(document).ready(function(){
  if($.browser.opera){
    $('a[href]').attr('tabindex', 0);
  }
});

...虽然这似乎适用于 Opera...是否有更好的解决方法?

In IE, Firefox, Chrome and most Windows-based interfaces that I've used, the Tab key can be used to navigate from one form field or hyperlink to the next (e.g. "actionable" items) (note: I have not tested on other Operating Systems)

However Safari and Opera skip all hyperlinks in a web page when tabbing. IMHO its a usability bug but I digress.

Is there a workaround/hack to make Safari and/or Opera navigate through these links?

I've noticed that Opera will accept the tabindex attribute if set e.g. tabindex="0" thus maintaining the links "index" within the flow of the DOM on the page... but Safari does not want to accept this.

For those interested, this bit of jQuery will make all the hyperlinks tabbable.

//Make links 'tab-able' in Opera
$(document).ready(function(){
  if($.browser.opera){
    $('a[href]').attr('tabindex', 0);
  }
});

...and although this seems to work for Opera... is there a better workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

饮惑 2024-08-29 06:22:40

在 Safari 中,这不是一个错误,而是一个可选功能。在 Mac 上,按 Tab 键选择链接以外的对象,按 Option+Tab 键选择所有对象。您可以在“首选项”->“高级”中交换这些快捷方式的行为。然后选项卡的行为就像在其他浏览器中一样。

在 Windows 上,Option+Tab 不可用。默认情况下,选项卡选择链接以外的对象,但“首选项”->“高级”中有一个选项可以使选项卡选择所有对象。然后选项卡的行为就像在其他浏览器中一样。

您可能不应该尝试干扰这一点,因为您会干扰用户的偏好。

In Safari, it's not a bug, it's an optional feature. On the Mac, tab selects objects other than links, Option+Tab select all objects. You can swap the behavior of these shortcuts in Preferences->Advanced. Then tab will behave like in other browsers.

On Windows, Option+Tab is not available. By default tab selects objects other than links , but there is an option in Preferences->Advanced that makes tab select all objects. Then tab will behave like in other browsers.

You should probably not try to interfere with this, as you would interfere with the user's preferences.

俏︾媚 2024-08-29 06:22:40

Actually this is a bug, according to the spec (see below) anchors (<a> elements) are supposed to accept the tabindex property, and a tabindex of 0 should make it focusable in the order the elements appear in the document.

http://www.w3.org/TR/html401/interact/forms.html#adef-tabindex

死开点丶别碍眼 2024-08-29 06:22:40

Opera 传统上认为这是一个功能,而不是一个错误(我们有并且还有其他用于导航链接的快捷键,当您了解这些快捷键时,您可能会发现为链接和表单元素提供不同的导航很有用 - 尝试过 Shift+箭头 空间导航吗? )。对于某些人来说,它仍然是一个功能。真实的轶事:曾几何时,内部构建意外地使链接成为可选项,这导致了如此多的错误报告和投诉,因此很快就被撤销了。 (据我记得,也是因为选项卡在其他方面有问题)。

然而,我们知道,大多数用户都期望使用 Tab 键切换到链接,因此我们应该像 Safari 一样为此实现一个首选项。同时,您可以将上面的 JS 修复之类的内容添加到用户 javascript 中,以便具有指向所有网站上链接的选项卡导航。

Opera traditionally thought this was a feature, not a bug (we had and have other key shortcuts for navigating links, when you know those you might find it useful to have distinct navigation for links and form elements - tried shift+arrow spatial navigation yet?). To some people it still is a feature. True anecdote: once upon a time an internal build made links tab'able by accident and this caused so many bug reports and complaints it was promptly reversed. (As far as I remember, also because the tabbing was buggy in other ways).

We know, however, that tabbing to links is something most users expect and that we should implement a pref for this like Safari has. In the meantime, you can add something like your JS fix above to a user javascript to have tab navigation to links on all websites out there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文