简体   繁体   English

IE11中聚焦的activeElement错误

[英]Wrong activeElement in focus in IE11

In IE11 span element is in a focus state ( document.activeElement returns span ), but it element hasn't tabindex attribute and shouldn't be in focus. 在IE11中, span元素处于焦点状态( document.activeElement返回span ),但是它没有tabindex属性,因此不应处于焦点状态。

Works fine in Chrome and Firefox (after click in focus div element with tabindex attribute). 在Chrome和Firefox中工作正常(在单击具有tabindex属性的focus div元素之后)。 The problem only in IE11. 仅在IE11中存在问题。 BTW, cannot reproduce this issue on the jsbin. 顺便说一句,无法在jsbin上重现此问题。

例

http://i.stack.imgur.com/2qdmJ.png http://i.stack.imgur.com/2qdmJ.png

I also don't see span in a list of elements that can get focus. 我也看不到可以集中注意力的元素列表中的span。

Is it a known problem? 这是一个已知问题吗? How to make div with tabindex as an activeElement after clicking on the span? 单击范围后,如何使用tabindex作为activeElement来制作div

http://msdn.microsoft.com/en-us/library/ms536934.aspx http://msdn.microsoft.com/en-us/library/ms536934.aspx

Finally I found that it's unexpected behavior in IE11 and possible bug if span has display: flex . 最终,我发现这是IE11中的意外行为,如果span display: flex ,可能是错误display: flex Chrome and Firefox after click on span return div and IE returns span . 单击span后,Chrome和Firefox返回div而IE返回span

Check snippet for details. 查看摘要以获取详细信息。 Reported on caniuse and probably should be added to IE tracker. 报告有关犬的情况,可能应该添加到IE跟踪器中。

 document.getElementById('d').addEventListener('click', function() { alert('active element is ' + document.activeElement); }); 
 #d { display: flex; } span { display: -ms-flex; display: flex; } 
 <div id='d' tabindex="1"> <div> <span>span</span> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM