40
4

5 回答 5

179

或者,您可以选择纯 HTML 解决方案。

<a href="http://foo.bar" tabindex="-1">inaccessible by tab link</a>

HTML5 规范说:

如果值为负整数
用户代理必须设置元素的 tabindex 焦点标志,但不应允许使用顺序焦点导航到达该元素。

于 2009-01-19T10:09:40.433 回答
4

我必须防止 div 和 overflow: auto css rule 之前有一个制表位,而我所做的是(转置为 a's):

var links = document.getElementsByTagName( 'a' );

for( var i = 0, j =  links.length; i < j; i++ ) {
    links[i].setAttribute( 'tabindex', '-1' );
}

使用 tabindex 而不是模糊意味着焦点将跳到下一个元素。

您确定要禁用 tabindex 吗?这对于没有鼠标的导航至关重要。

刚刚注意到纯 HTML 中的类似答案

于 2009-01-19T10:16:23.540 回答
0

尝试

<a onfocus="this.blur();" href = "bla">Bla</a>
于 2009-01-19T09:56:50.180 回答
0

标签<a>必须能够被标签索引。它使导航更容易。

使用<p><span>代替,宽度onclick="window.location.href='URL'"事件属性。

例子:

<span onclick="window.location.href='http://www.w3schools.com'">text that redirects you to W3S on click, where you can read more about HTML standards.</span>
于 2011-09-16T11:43:41.440 回答
-5
于 2009-01-19T09:57:29.023 回答