Is it possible to use javascript to detect if a screen reader is running on a users machine?

孤者浪人 提交于 2019-11-30 07:57:18

问题


I want to detect whether a screen reader is running on a user's machine to avoid sound clashing with audio tag in html. If so, please provide details on how this could be done.


回答1:


You should probably not try to do anything special even if you could detect that a screenreader is running. Even if you get it right for one group of screenreader users, you may get it wrong for another group. It's best to concentrate on writing good clean HTML5 in the first place.

Note that not all screenreader users use text-to-speech; many use braille output. Additionally, other types of accessibility tools - such as content highlighters and voice input apps - use the same techniques and APIs (eg. DOM, MSAA) that screenreaders do, so any technique that "detects a screenreader" will likely detect these also - so you cannot assume that it means that the user is fully blind and using only speech.

As things currently stand, the audio tag is currently not universally accessible, different browsers have different levels of accessibility support - see HTML5 Accessibility and scroll down to audio for more details of current support. I've seen some pages that add HTML5-based controls plus javascript after the audio tag so they can provide their own UI to ensure that keyboard or screenreader users can play/stop the audio as needed. (Eventually, when browsers catch up, this should not be needed.)

As far as general accessibility goes, WCAG 2.0 (Web Content Accessibility Guidelines) recommends that any audio that plays automatically for more than 3 seconds should have an accessible means to pause or stop the audio. (I'd go even further and recommend against using any automatic audio - when using tabbed browsing, it's often impossible to determine which tab the audio is coming from.)




回答2:


You cannot detect screen readers using javascript, you cannot detect screen readers using any client side technology. You can detect software that is running an MSAA client using Flash. More details about how it works and why it is not useful and should not be used to detect screen readers is available here: Developer Beware: Using Flash to Detect Screen Readers




回答3:


While likely not a fully reliable way, a screen reader's progress can be detected via javascript using the focus event, as the user skim though content.

A hidden "skip navigation link" (http://webaim.org/techniques/skipnav/) should it be focused, would be one way to detect whether someone is using a screenreader.

Even though it doesn't address the audio part of the question, I just wanted to provide this partial solution, as I was looking for possible ways to detect screen-readers myself.



来源:https://stackoverflow.com/questions/7712167/is-it-possible-to-use-javascript-to-detect-if-a-screen-reader-is-running-on-a-us

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