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

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

问题描述

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

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.

推荐答案

即使您可以检测到屏幕阅读器正在运行,您也不应该尝试做任何特殊的事情.即使您对一组屏幕阅读器用户来说是正确的,对于另一组用户来说也可能是错误的.最好一开始就专注于编写干净的 HTML5.

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.

请注意,并非所有屏幕阅读器用户都使用文本转语音;许多使用盲文输出.此外,其他类型的辅助功能工具——例如内容荧光笔和语音输入应用程序——使用与屏幕阅读器相同的技术和 API(例如 DOM、MSAA),因此任何检测屏幕阅读器"的技术也可能会检测到这些——所以您不能假设这意味着用户完全失明并且只使用语音.

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.

就目前的情况而言,音频标签目前并非普遍可访问,不同的浏览器具有不同级别的可访问性支持 - 请参阅 HTML5 可访问性 并向下滚动到音频以了解当前支持的更多详细信息.我已经看到一些页面在音频标签之后添加了基于 HTML5 的控件和 javascript,这样他们就可以提供自己的 UI,以确保键盘或屏幕阅读器用户可以根据需要播放/停止音频.(最终,当浏览器迎头赶上时,这应该是不需要的.)

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

就一般可访问性而言,WCAG 2.0(Web 内容可访问性指南)建议任何自动播放超过 3 秒的音频都应具有暂停或停止音频的可访问方式.(我更进一步,建议不要使用任何自动音频 - 使用标签浏览时,通常无法确定音频来自哪个标签.)

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天全站免登陆