逐浪云主机

立即开通

ARIA(Accessible Rich Internet Application)友好访问应用介绍

作者: 发布时间:2020-02-20 来源:佚名 点击数:

ARIA 为Web app提供满足用户不同需求的解决方案。建设起用户和软件之间的桥梁。
新的HTML5标准中增加 aria-* 的标签属性,全称Accessible Rich Internet Application。与role标签属性配合使用。
role属性表示一个非标准的tag的实际作用。比如用divbutton,那么设置divrole=“button”,辅助工具就可以认出这实际上是个button。而aria-*的作用就是描述这个tag在可视化的情境中的具体信息。

最简单的应用比如,

<div role="checkbox" aria-checked="checked"></div>

辅助工具就会知道,这个div实际上是个checkbox的角色,为选中状态。

Accessible Rich Internet Applications (ARIA) 是能够让残障人士更加便利的访问 Web 内容和使用 Web 应用(特别是那些由JavaScript 开发的)的一套机制。

ARIA是对超文本标记语言(HTML )的补充,以便在没有其他机制的情况下,使得应用程序中常用的交互和小部件可以传递给辅助交互技术。例如,ARIA支持HTML4中的可访问导航地标、JavaScript小部件、表单提示和错误消息、实时内容更新等。

ARIA 是一组特殊的易用性属性,可以添加到任意标签上,尤其适用于 HTML。role 属性定义了对象的通用类型(例如文章、警告,或幻灯片)。额外的 ARIA 属性提供了其他有用的特性,例如表单的描述或进度条的当前值。

ARIA 在大多数流行的浏览器和屏幕阅读器中得到了实现。尽管如此,实现方式有所不同,而且旧的技术对其支持不好(或者不支持)。使用可以优雅降级的“安全的” ARIA,或者要求用户升级使用新的技术。

这些小部件中的许多后来被合并到HTML5中,如果存在这样的元素,开发人员应该更倾向使用对应的语义化HTML元素,而不是使用ARIA。例如,原生元素具有内置的键盘可访问性、角色和状态。但是,如果您选择使用ARIA,您有责任在脚本中模仿(等效的)浏览器行为。

下面是一段进度条组件的代码:

<div id="percent-loaded" role="progressbar" aria-valuenow="75" 
     aria-valuemin="0" aria-valuemax="100" />

由于这个滚动条是用<div>写的,没有字面含义。然而,对开发者来说,在HTML4中,又没有更多的语义化的标签,所以我们需要引入ARIA这个角色和属性,这些是通过向元素添加属性来指定的。举个例子,role="progressbar"这个属性告诉浏览器,该元素其实是一个JavaScript实现的进度条组件。aria-valueminaria-valuemax 属性表明了进度条的最小值和最大值。 aria-valuenow则描述了当前进度条的状态, 因此它得用JavaScript来更新。

除了直接给标签加属性,还可以通过JavaScript代码把ARIA属性添加到元素并动态地更新,如下面所示:

    // Find the progress bar <div> in the DOM.
     var progressBar = document.getElementById("percent-loaded");

    // Set its ARIA roles and states, 
    // so that assistive technologies know what kind of widget it is.
     progressBar.setAttribute("role", "progressbar");
     progressBar.setAttribute("aria-valuemin", 0);
     progressBar.setAttribute("aria-valuemax", 100);

    // Create a function that can be called at any time to update 
    // the value of the progress bar.
     function updateProgress(percentComplete) {
       progressBar.setAttribute("aria-valuenow", percentComplete);
     }

注意由于ARIA是在HTML4之后引入的,所以在HTML4或XTHML中没有提供验证。然而,它提供的可访问性收益远远超过任何技术上的无效性。

在HTML5中,所有的ARIA属性都是有效的。新的标记元素(<main>, <header>, <nav>等)都已具有了ARIA角色,所以就没必要再标注说明了。

ARIA 入门

ARIA 介绍

关于借助 ARIA 使得动态内容可访问的快速介绍。也可参考经典的 ARIA 介绍 - Gez Lemon,2008 年。
http://dev.opera.com/articles/view/introduction-to-wai-aria/

Web 应用与 ARIA FAQ

解答关于WAI-ARIA的问题并且解释为什么网站需要ARIA。
https://developer.mozilla.org/en-US/docs/Accessibility/ARIA/Web_applications_and_ARIA_FAQ

在视频频和屏幕阅读器使用 ARIA

从网上看到真实和简单的例子,包括“before”和“after”ARIA视频。
http://zomigi.com/blog/videos-of-screen-readers-using-aria-updated/

在 HTML 使用 ARIA

A practical guide for developers. It suggests what ARIA attributes to use on HTML elements. Suggestions are based on implementation realities.一份为开发人员提供实用指南。它建议一些基于基于执行的在HTML元素上使用哪些ARIA属性。
http://dvcs.w3.org/hg/aria-unofficial/raw-file/tip/index.html

ARIA 初级进阶

通过ARIA标签增强页面导航

http://www.paciellogroup.com/blog/2010/10/using-wai-aria-landmark-roles/
A nice intro to using ARIA landmarks to improve web page navigation for screen reader users. See also, ARIA landmark implementation notes and examples on real sites (updated as of July ‘11).

提高表单可访问性

ARIA is not just for dynamic content! Learn how to improve accessibility of HTML forms using additional ARIA attributes.
https://developer.mozilla.org/en-US/docs/ARIA/forms

ARIA Live Regions(正在完善中)

Live regions provide suggestions to screen readers about how to handle changes to the contents of a page.
http://www.freedomscientific.com/Training/Surfs-up/AriaLiveRegions.htm

用ARIA Live Regions去通知内容的改变

A quick summary of live regions, by the makers of JAWS screen reader software. Note that live regions are also supported by NVDA in Firefox, and VoiceOver with Safari (as of OS X Lion and iOS 5).
http://www.freedomscientific.com/Training/Surfs-up/AriaLiveRegions.htm

ARIA 与脚本组件

键盘导航与组件焦点

The first step in developing an accessible JavaScript widget is to make it keyboard navigable. This article steps through the process. The Yahoo! focus management article is a great resource as well.
https://developer.mozilla.org/en-US/docs/Accessibility/Keyboard-navigable_JavaScript_widgets

Style Guide for Keyboard Navigation

A challenge with ARIA is getting developers to implement consistent behavior — clearly best for users. This style guide describes the keyboard interface for common widgets.
http://access.aol.com/dhtml-style-guide-working-group/

ARIA 资源

Widget Techniques, Tutorials, and Examples

Need a slider, a menu, or another kind of widget? Find resources here.
https://developer.mozilla.org/en-US/docs/Accessibility/ARIA/widgets/overview

ARIA-Enabled JavaScript UI Libraries

If you’re starting a new project, choose a UI widget library with ARIA support already built-in. Warning: this is from 2009 — content should be moved to an MDN page where it can be updated.
http://www.paciellogroup.com/blog/2009/07/wai-aria-implementation-in-javascript-ui-libraries/

Accessibility of HTML5 and Rich Internet Applications - CSUN 2012 Workshop Materials

Includes slide presentations and examples.
http://dl.dropbox.com/u/573324/CSUN2012/index.html

参考文献:https://developer.mozilla.org/zh-CN/docs/Web/Accessibility/ARIA

本文责任编辑: 加入会员收藏夹 点此参与评论>>
复制本网址-发给QQ/微信上的朋友