如何防止SVG元素通过IE11中的标签获得焦点? [英] How to prevent SVG elements from gaining focus with tabs in IE11?

查看:217
本文介绍了如何防止SVG元素通过IE11中的标签获得焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTML表单元素中有一个内联SVG元素.当我使用Tab键浏览元素时,即使SVG元素的tabindex="-1"属性设置为其中的每个元素,SVG元素也仅在IE11中被聚焦:

There is an inline SVG element among my HTML form elements. When I navigate through my elements with the Tab key, the SVG element gets focused, in IE11 only, even if the SVG element has the tabindex="-1" attribute set to every element inside it:

<svg width="20px" height="20px" tabindex="-1">
    <g tabindex="-1">
      <circle cx="8.5" cy="8.5" r="7.75" stroke="#999" stroke-width="1" tabindex="-1" />
      […]
    </g>
</svg>

为了确保它专注于该元素,我在控制台中调用了document.activeElement,是的,它可以打印出SVG内容.

To be sure that it's focusing on that element, I call document.activeElement in the console, and yes, it prints out the SVG thing.

Internet Explorer 11应该像其他DOM元素一样接受负值,还是不应该? 我应该怎么做才能防止这种情况发生?

Internet Explorer 11 should honor the negative value, as it does for other DOM elements, or should it not? What can I possibly do to prevent this?

推荐答案

万一您错过了它,答案将被评论:

In case you missed it, the answer was commented:

tabindex是即将推出的SVG2的一部分,IE11尚不支持.请查看此问题,以解决此问题.

tabindex is part of upcoming SVG2 and is not yet supported by IE11. Have a look at this question for a work-around.

该问题的答案建议向SVG元素添加focusable="false"属性.

The answer in that question recommends adding a focusable="false" attribute to the SVG element.

感谢@altocumulus

Thanks to @altocumulus

这篇关于如何防止SVG元素通过IE11中的标签获得焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆