Is it possible to use javascript to detect if a sc

2019-01-25 03:14发布

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.

4条回答
家丑人穷心不美
2楼-- · 2019-01-25 03:15

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.)

查看更多
太酷不给撩
3楼-- · 2019-01-25 03:18

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-25 03:19

Follow the link http://northtemple.com/2008/10/07/javascript-and-screen-readers Your problem get definitely resolved.

查看更多
放我归山
5楼-- · 2019-01-25 03:32

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

查看更多
登录 后发表回答