How to prevent Windows Narrator from reading hidden HTML tags?

廉价感情. 提交于 2019-12-11 10:18:32

问题


I have an HTML page, with multiple hidden elements that become visible only under certain circumstances.

When I set the focus on the page wrapper (to read all the content), Windows Narrator reads all the elements, even the hidden ones.

I have tried using aria-hidden="true", CSS display: none, HTML5 hidden attribute, all are completely ignored. So far, the only mechanism that I found that works is to remove this elements from the DOM, before setting the focus on the wrapper. But it's not an ideal solution.


回答1:


apply role="presentation" tabindex="-1" to your elements that have aria-hidden applied.




回答2:


Just fought with the same thing, and found out that if there's an element with role="main" without explicit aria-label/aria-labelledby defined, its whole content, including all the hidden elements, is added to MSAA and UIA trees which is then read out by the Narrator. Adding an explicit aria property solves the issue - but apparently also stops the Narrator from starting to read the main content automatically.

The good thing is that AccChecker warns about these problems. Apparently better to follow its advice even though it would be nice to have that automatic reading of content.




回答3:


Apparently this isn't an issue anymore on MS Edge! Hurray! If the element is hidden with CSS display:none then it doesn't read it's content.



来源:https://stackoverflow.com/questions/17832000/how-to-prevent-windows-narrator-from-reading-hidden-html-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!