[英]Remove HTML tag from tab order
In my app's tab loop, the <html>
tag occupies a tab stop. 在我的应用程序选项卡循环中,
<html>
标记占用制表位。 I'm looking to remove the <html>
tag from the tap loop. 我想从tap循环中删除
<html>
标签。
I tried adding tabindex="-1"
to the <html>
tag, but on IE11 at least, that did not seem to remove the element from the tab loop. 我尝试将
tabindex="-1"
到<html>
标签,但至少在IE11上,似乎没有从标签循环中删除该元素。 I'm close to spinning my own logic using JS to "skip" to the next focusable element if document.activeElement === <html>
, but I'm wondering if there's an easier way. 如果
document.activeElement === <html>
,我接近于使用JS来“跳转”到下一个可聚焦元素,但是我想知道是否有更简单的方法。
The solution needs to be supported cross the major browsers: IE11, Edge, FF, Chrome, Safari. 需要跨主流浏览器支持该解决方案:IE11,Edge,FF,Chrome,Safari。
Any ideas? 有任何想法吗?
I visited HTML specification for tabindex attribute -> https://html.spec.whatwg.org/#the-tabindex-attribute 我访问了tabindex属性的HTML规范 - > https://html.spec.whatwg.org/#the-tabindex-attribute
Below is the second para: 以下是第二段:
As it is clearly mentioned that the only way to make any element not focusable is by making it disable or make it invisible from DOM. 正如清楚地提到的那样,使任何元素不可聚焦的唯一方法是使其禁用或使其从DOM中不可见。
I am still searching and will post an update on this. 我仍在搜索并将发布此更新。
Moreover, I also tried to replicate this issue and could not do it on IE.(did not try to replicate on other browser). 此外,我也试图复制这个问题,并且无法在IE上执行此操作。(没有尝试在其他浏览器上复制)。
I found the difference in tabIndex between HTML4 AND HTML5 : 我在HTML4和HTML5之间找到了tabIndex的区别 :
It is stated that though HTML5 allows adding tabIndex attributes on any element, it may not have any effect. 据说尽管HTML5允许在任何元素上添加tabIndex属性,但它可能没有任何效果。 This is applicable to HTML element also.
这也适用于HTML元素。 My I know, how do we know if an HTML element is focused?
我知道,我们如何知道HTML元素是否集中?
Well according to my simple research i have found that you can use You can use tabindex="-1"
. 根据我的简单研究,我发现你可以使用你可以使用
tabindex="-1"
。
The W3C HTML5 specification supports negative tabindex values. W3C HTML5规范支持负tabindex值。
You can use also,which works for most browsers: 您也可以使用,适用于大多数浏览器:
element.removeAttribute('tabindex');
I find this way with jquery but i'm not sure about 我用jquery找到这种方式,但我不确定
$('#yourelment').prop('tabIndex', -1);
Please check those link for more details : 请查看这些链接了解更多详情:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.