简体   繁体   English

window.confirm() 是否可以访问?

[英]Is window.confirm() accessible?

window.confirmwindow.alertwindow.prompt这样的原生浏览器模式是否可以访问,还是实现一些自定义的东西更好?

There isn't a whole lot of info out there on this, but I believe the answer is yes (for the most part).关于这方面的信息并不多,但我相信答案是肯定的(在大多数情况下)。 It seems that previously screen readers didn't have support for alerts/window dialogs but screen readers have come to support these in today's world.以前的屏幕阅读器似乎不支持警报/窗口对话框,但在当今世界,屏幕阅读器已经开始支持这些。

"Although JavaScript pop-up alert boxes were once discouraged by accessibility experts, modern screen readers and browsers provide excellent support for the basic JavaScript alert box." “虽然 JavaScript 弹出式警告框曾经被可访问性专家劝阻,但现代屏幕阅读器和浏览器为基本的 JavaScript 警告框提供了出色的支持。”

http://accessibility.psu.edu/scripts/alertboxes/#basic http://accessibility.psu.edu/scripts/alertboxes/#basic

https://www.w3.org/TR/2018/WD-wai-aria-practices-1.2-20180719/examples/dialog-modal/alertdialog.html https://www.w3.org/TR/2018/WD-wai-aria-practices-1.2-20180719/examples/dialog-modal/alertdialog.html

Reading through the w3 documentation, it seems as though it's more preferred to make your own and specify the appropriate aria attributes通读 w3 文档,似乎更喜欢自己制作并指定适当的aria属性

Update: Read the bottom of this answer.更新:阅读此答案的底部。 According to this answer , they are accessible to most screen-readers, but not JAWS which (as of this December 2017 article) has 46% of the market share.根据这个答案,大多数屏幕阅读器都可以访问它们,但 JAWS 不可以(截至2017 年 12 月的这篇文章)拥有 46% 的市场份额。 So, 46% of the people using screen-readers uses a screen-reader that does not support window.confirm , so it is probably better to make a custom dialog box with the respective aria-* attributes.因此,使用屏幕阅读器的人中有 46% 使用的屏幕阅读器不支持window.confirm ,因此最好使用各自的aria-*属性制作自定义对话框。



Edit: According to a comment from Travis J., the github issue shows that is was a Chrome bug, which has been patched . 编辑:根据 Travis J. 的评论, github 问题表明这是一个 Chrome 错误,已被修补 However, if you want to keep support for older versions of Chrome, then you can make a custom dialog box, or just make a custom one if you want to add CSS, make more buttons, etc. 但是,如果您想保持对旧版 Chrome 的支持,那么您可以创建一个自定义对话框,或者如果您想添加 CSS、创建更多按钮等,只需创建一个自定义对话框。

My testing gives these results:我的测试给出了这些结果:

  1. Both JAWS and NVDA with Firefox in Windows announce a window.confirm() dialog correctly, but Firefox permits keyboard navigation to leak out of the dialog while JAWS or NVDA is on or off. Windows 中的 JAWS 和 NVDA 与 Firefox 都正确地宣布 window.confirm() 对话框,但 Firefox 允许在 JAWS 或 NVDA 打开或关闭时键盘导航泄漏到对话框之外。 That is a serious accessibility defect.这是一个严重的可访问性缺陷。
  2. Both JAWS and NVDA with Chrome in Windows fail to announce the text content of a window.confirm() dialog at all, so the user listening to JAWS or NVDA cannot know what the "OK" and "Cancel" buttons are confirming or canceling. Windows 中的 JAWS 和带有 Chrome 的 NVDA 根本无法宣布 window.confirm() 对话框的文本内容,因此收听 JAWS 或 NVDA 的用户无法知道“确定”和“取消”按钮是确认还是取消。 That is a fatal accessibility defect.这是一个致命的可访问性缺陷。
  3. VoiceOver with Safari in OS X announces "From" and the URL, but otherwise announces nothing when a window.confirm() dialog opens. OS X 中带有 Safari 的 VoiceOver 会播报“发件人”和 URL,但在 window.confirm() 对话框打开时不会播报任何内容。 If the user then navigates forward with the keyboard, VoiceOver announces the "Cancel" and "OK" buttons, but never announces the text content that explains those buttons.如果用户随后使用键盘向前导航,VoiceOver 会报出“取消”和“确定”按钮,但不会报出解释这些按钮的文本内容。 That is a fatal accessibility defect.这是一个致命的可访问性缺陷。 Safari also permits keyboard navigation to leak out of the dialog while VoiceOver is on or off, a serious accessibility defect. Safari 还允许在打开或关闭 VoiceOver 时键盘导航从对话框中泄漏,这是一个严重的可访问性缺陷。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM