How to prevent screen reader from reading src attribute from img tag in IE

我与影子孤独终老i 提交于 2019-12-24 12:35:02

问题


I am facing a very straight forward problem with screen readers in IE9 or below. When the screen reader looks at an image tag, which has the src attribute, it reads the content of the src. Even if the alt attribute is present, it reads the contents inside the src.

To be perfectly clear: this only happens in IE 9 or below

Here is a very simple example of my code:

<img src="http://placehold.it/100x100" alt="some image"/>

I don't understand why this is happening. Any help on how to get around this issue or the fact that no, there is not solution plus proof, would be very appreciated.


回答1:


I think you're hitting a bug with a new verison of NVDA, and an old version of IE.

Try the code with Firefox (recent) and NVDA, or a version of JAWs from the IE9 era (version 12 I think would do), and I'm fairly sure you'll get the alt text.

In terms of proof, the official document for this is the WAI ARIA roles "Text alternative computation", which then refers to the HTML4 "How to specify alternative text".

Basically, the alt text is what should be used, you're hitting a bug in a combination of screenreader and browsers that are very unlikely to be used together. (NVDA works best with Firefox, you would use Jaws with IE9.)




回答2:


I think you should try using a 'title' attribute. A lot of times, 'title' is what is used for readers to get the description.

<img src=".." alt=".." title="some image" />

Hope this helps!



来源:https://stackoverflow.com/questions/33112473/how-to-prevent-screen-reader-from-reading-src-attribute-from-img-tag-in-ie

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