简体   繁体   English

如何使这个 javascript 应用程序可访问?

[英]how to make this javascript application accessible?

Im making an FTP client, which will rely a lot on javascript.我正在制作一个 FTP 客户端,它将在很大程度上依赖于 javascript。

When browsing through the files, you can navigate using the arrow keys.浏览文件时,您可以使用箭头键进行导航。 I add a class of.selected to the currently selected filename, but how can I make this clear to screenreaders?我将 class of.selected 添加到当前选定的文件名中,但是如何让屏幕阅读器清楚这一点? How do I make them focus on the current filename?如何让他们专注于当前文件名?

Would the best way be to make every filename an anchor, which will get the focus when the filename is selected? Would the best way be to make every filename an anchor, which will get the focus when the filename is selected? And also, where can I find a good guide on web application accessibility?而且,我在哪里可以找到关于 web 应用程序可访问性的良好指南? I know the W3C has a checklist for content accessibility, but most of the points there don't apply to web apps.我知道 W3C 有一个内容可访问性清单,但其中的大部分内容不适用于 web 应用程序。

Simplest way to do this is perhaps to have a series of checkboxes, each with a unique ID, paired with a label:最简单的方法可能是使用一系列复选框,每个复选框都有一个唯一的 ID,并与 label 配对:

<input id="chk01" type="checkbox"/><label for="chk01">File1.txt</label>

Using this technique, the input is doing the work of exposing a selected-ness for you, while the label takes care of associating it with the name: when focus goes to the checkbox, the screenreader will automatically read out the associated label text.使用这种技术,输入会为您显示选定内容,而 label 负责将其与名称相关联:当焦点转到复选框时,屏幕阅读器将自动读出相关的 label 文本。 It's all plain HTML, nothing special required.都是普通的 HTML,没有什么特别要求。 You're free of course to add in selection coloring on top of this - so long as you keep it in sync with checkbox state.您当然可以在此之上添加选择颜色 - 只要您将其与复选框 state 保持同步。

It may be possible to do something similar with A tags;可以用 A 标签做类似的事情; you can use WAI-ARIA properties to set role="listitem" and aria-selected="true"/"false" as appropriate on the items, with role="list" on the parent container.您可以使用WAI-ARIA属性在项目上适当设置 role="listitem" 和 aria-selected="true"/"false",在父容器上设置 role="list"。 A screenreader will then read these out as list items, rather than links.然后,屏幕阅读器会将这些内容作为列表项而不是链接读出。 This technique is more involved, however, and would really need to be tested with an actual screen reader (eg JAWS, or the freely-available NVDA) to ensure it works.然而,这种技术涉及更多,并且确实需要使用实际的屏幕阅读器(例如 JAWS 或免费提供的 NVDA)进行测试,以确保其正常工作。

I would suggest you use a javascript framework to help with accessibility in conjunction with WAI-ARIA For examples of accessible jQuery see https://github.com/fnagel/jQuery-Accessible-RIA/wiki and for examples of accessible drag and drop with WAI-ARIA see http://dev.opera.com/articles/view/accessible-drag-and-drop/我建议您使用 javascript 框架来帮助与WAI-ARIA结合使用可访问性有关可访问性 jQuery 的示例,请参阅https://github.com/fnagel/可访问性和可访问性拖放示例WAI-ARIA 见http://dev.opera.com/articles/view/accessible-drag-and-drop/

First - make sure your basics are covered.首先 - 确保您的基础知识已涵盖。 The Web Content Accessibility Guidelines (WCAG) don't cover interactivity well, but many of its points remain applicable to web applications. Web 内容可访问性指南 (WCAG) 没有很好地涵盖交互性,但它的许多要点仍然适用于 web 应用程序。

Next - learn about the ARIA standard for Accessible Rich Internet Applications.下一步 - 了解可访问富 Internet 应用程序的 ARIA 标准。 This will cover a lot of the interactivity you're trying for.这将涵盖您正在尝试的许多交互性。

Some relevant links:一些相关链接:

There are a number of books on accessibility, which tend to get outdated fairly fast.有许多关于可访问性的书籍,它们往往很快就会过时。 Sadly, I'm not aware of any book-length discussions of ARIA -- it's still in development.可悲的是,我不知道有任何关于 ARIA 的书籍长度的讨论——它仍在开发中。 Try reading the specs.尝试阅读规格。

Last but not least -- get a screen reader and learn to use it.最后但并非最不重要的 - 获取屏幕阅读器并学习使用它。 Formal compliance with accessibility standards is great, but nothing beats real testing.对可访问性标准的正式合规性很好,但没有什么比真正的测试更好的了。 NVDA is a free and fully featured screen reader that has decent support for ARIA: http://nvda-project.org/ NVDA 是一款免费且功能齐全的屏幕阅读器,对 ARIA 提供了不错的支持: http://nvda-project.org/

Hope this helps.希望这可以帮助。

When browsing through the files, you can navigate using the arrow keys.浏览文件时,您可以使用箭头键进行导航。

Building upon a previous answer that neglected this feature, wrap the entire widget in a div with role=application.建立在忽略此功能的先前答案的基础上,将整个小部件包装在一个 div 中,其中角色=应用程序。 This notifies the screen reader that JavaScript will be used and will allow the user to navigate the widget with the arrow keys while using a screen reader.这会通知屏幕阅读器 JavaScript 将被使用,并允许用户在使用屏幕阅读器时使用箭头键导航小部件。 The excerpt below details how to design the widget to be accessible.下面的摘录详细介绍了如何设计可访问的小部件。 Yes, it's not the simplest solution, but it is the most complete.是的,这不是最简单的解决方案,但它是最完整的。 Take your pick.任你选。

Description: A widget that allows the user to select one or more items from a list of choices. 描述:一个允许用户从选择列表中选择一个或多个项目的小部件。 ( listbox ). listbox )。 Keyboard Interaction: 键盘交互:
  • Tab : When a list is tabbed to, select the first item if nothing else is already selected. Tab :当一个列表被选项卡到,select 第一项如果没有其他已经被选中。 A second tab will take the user out of the widget to the next tab stop on the page.第二个选项卡会将用户从小部件中带到页面上的下一个制表位。
  • Up/down arrows navigate up and down the list.向上/向下箭头在列表中上下导航。
  • Shift+Up Arrow and Shift+Down Arrow move and extend the selection. Shift+向上箭头Shift+向下箭头移动和扩展选择。
  • Typing letter or several letters to navigate (same letter goes to each item starting with that, different letters go to first item starting with that entire string).键入字母或几个字母进行导航(相同的字母转到以该开头的每个项目,不同的字母 go 到以整个字符串开头的第一个项目)。
  • Shift+F10 : If the current item has an associated context menu, then this key combination will launch that menu. Shift+F10 :如果当前项目具有关联的上下文菜单,则此组合键将启动该菜单。
  • Selection选择
    • Checkbox - Space toggles checkboxes, if the list items are checkable复选框 -空格切换复选框,如果列表项是可检查的
    • Selectable List Items可选列表项
      • Space acts as a toggle to select and deselect the current item.空格作为切换到 select 并取消选择当前项目。 If previous items have been selected, it also deselects them and selects the current item.如果先前的项目已被选择,它也会取消选择它们并选择当前项目。
      • Shift+Space selects contiguous items from the last selected item to the current item. Shift+Space选择从最后一个选定项目到当前项目的连续项目。
      • Ctrl+Arrow moves without selecting. Ctrl+箭头移动而不选择。
      • Ctrl+Space selects non-contiguous items and adds the current selected item to all previously selected items. Ctrl+Space选择不连续的项目并将当前选定的项目添加到所有先前选定的项目中。
      • Ctrl+A - It is recommended a checkbox, link or other method be used to select all. Ctrl+A - 建议对 select 全部使用复选框、链接或其他方法。 The Ctrl+A key could be used to provide the shortcut key. Ctrl+A键可用于提供快捷键。
It is recommended the developer use different styling for the selection when the list is not focused (hint: non-active selection is often shown with a lighter background color). 建议开发人员在列表未聚焦时使用不同的样式进行选择(提示:非活动选择通常以较浅的背景颜色显示)。

WAI-ARIA Roles, States, and Properties: WAI-ARIA 角色、状态和属性:
  • The listbox container has a role of listbox . listbox 容器的作用是listbox
  • Each entry in the listbox should have a role option and should be DOM children of listbox .列表框中的每个条目都应该有一个角色option ,并且应该是listbox的 DOM 子项。
  • If is not a DOM child of listbox, then it should be referenced in the listbox by aria-owns .如果不是列表框的 DOM 子项,则它应该由aria-owns在列表框中引用。
  • If all items in the listbox are not DOM children of the listbox, then set their aria-setsize and aria-posinset accordingly;如果列表框中的所有项目都不是列表框的 DOM 子项,则相应地设置它们的aria-setsizearia-posinset otherwise, this information cannot be computed for context by the user agent.否则,用户代理无法为上下文计算此信息。
  • If the listbox is not part of another widget, then it should have a visible aria-label referenced on the listbox by aria-labelledby .如果列表框不是另一个小部件的一部分,那么它应该有一个可见的aria-labelaria-labelledby在列表框上引用。
  • Each selected list item should have aria-selected ="true".每个选定的列表项都应具有aria-selected ="true"。

Examples:例子:

Single select listbox单 select 列表框

Listbox in an iframe iframe 中的列表框

Refer to the authoring practices for accessible widgets for examples and more information.有关示例和更多信息,请参阅可访问小部件的创作实践

From what I understand, YUI has a large amount of support for ARIA.据我了解,YUI 对 ARIA 有很大的支持。

See:看:

http://developer.yahoo.com/yui/theater/video.php?v=kloots-yuiconf2009-a11y http://developer.yahoo.com/yui/theater/video.php?v=kloots-yuiconf2009-a11y

Make sure your solution conforms to ARIA:确保您的解决方案符合 ARIA:

http://www.w3.org/WAI/intro/aria.php http://www.w3.org/WAI/intro/aria.php

HTH HTH

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

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