是否有可能使用JavaScript来检测屏幕阅读器是否在用户计算机上运行? [英] Is it possible to use javascript to detect if a screen reader is running on a users machine?

查看:81
本文介绍了是否有可能使用JavaScript来检测屏幕阅读器是否在用户计算机上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测屏幕阅读器是否在用户机器上运行,以避免与html中的音频标签发生声音冲突。如果是这样,请提供详细信息,说明如何做到这一点。 解决方案

可以检测到屏幕阅读器正在运行。即使您为一组屏幕阅读器用户正确使用,您也可能会为另一个组织错误。注意,并非所有的屏幕阅读器用户都使用文本到语音转换,而不是所有的屏幕阅读器用户。许多使用盲文输出。此外,其他类型的辅助功能工具(如内容荧光笔和语音输入应用程序)使用屏幕阅读器所使用的相同技术和API(例如DOM,MSAA),因此任何检测屏幕阅读器的技术都可能会检测到这些 - 所以你不能认为这意味着用户完全失明,只能使用语音。

目前,音频标签目前还没有普及到,不同的浏览器有不同的可访问性支持级别 - 请参阅 HTML5辅助功能并向下滚动至音频以获取当前支持的更多详细信息。我已经看到了一些在音频标签之后添加了基于HTML5的控件和JavaScript的页面,以便他们可以提供自己的UI以确保键盘或屏幕阅读器用户可以根据需要播放/停止音频。 (最终,当浏览器赶上时,这不应该被需要。)



就一般的可访问性而言,WCAG 2.0( Web Content Accessibility Guidelines )建议任何自动播放时间超过3秒的音频应该有可用的方法来暂停或停止音频。 (我会更进一步,建议不要使用任何自动音频 - 使用标签浏览时,通常不可能确定音频来自哪个标签。)


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.

解决方案

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

这篇关于是否有可能使用JavaScript来检测屏幕阅读器是否在用户计算机上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆