Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 623
shuklendu Avatar asked Oct 10 '11 11:10

shuklendu


People also ask

Can you detect if a user is using a screen reader?

The short answer is that you can't. At the time of writing there isn't a way to reliably detect whether someone visiting your site is using a screen reader (or screen magnifier). You might have heard that Flash will do the trick, but that might not be quite the solution you're expecting.

Do screen readers work with Javascript?

They don't parse the HTML directly but an accessible tree view of a document. This means that if your browser understands javascript, your screenreader will. That because, your screen reader will not access the DOM directly on the load of the page, but will interact with the Accessibility API provided by your browser.

How do I test my screen reader?

The most obvious way to test for screen reader compatibility is by using screen reader software to navigate your digital content and run through the key user flows to fully understand the experience. However, using a screen reader like JAWS for testing requires knowing how to use it properly.

What does a screen reader see?

A screen reader is a software application that interprets things on the screen (text, images, links, and so on) and converts these to a format that visually impaired people are able to consume and interact with.


2 Answers

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

like image 135
BrendanMcK Avatar answered Sep 26 '22 08:09

BrendanMcK


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.

like image 35
hexalys Avatar answered Sep 26 '22 08:09

hexalys