How to label a loading animation for WAI-ARIA?

元气小坏坏 提交于 2019-12-12 10:38:47

问题


I'm working on fixing some accessibility issues on a web page. I have this div that acts as a dialog, and inside at one point a div containing a loading animation and a text "Working..." is displayed.

I am unsure as to how to label these two items in order to correctly notify the blind user that there is a progress animation and that it's working and he should wait.

<div id="loading" style="display: none;">
        <div class="mgBot15"><span class="txt16" role="alert">Working...</span></div>
        <img src="loading.png" role="progressbar" aria-busy="true"/>
    </div>

I tried adding the role and aria-busy properties to the img (also to the parent div, at first).

When this div appears (by changing the display style property), it correctly reads "Working..." but I hear no indication that it's busy and that the user should wait, am I missing something?

I've looked all over for examples for loading animations, to no avail so far.

Note: I'm using NVDA as a screenreader to test.

Thanks


回答1:


The best solution I could come up with was using role alert, and aria-busy="true".

<div id="loading" style="display: none;">
    <div class="mgBot15"><span class="txt16" role="alert" aria-busy="true">Working...</span></div>
    <img src="loading.png" alt="loading" />
</div>



回答2:


I believe the most sensible approach would to use the combo aria-busy="true" aria-live="polite"

The reason for that is because some pages might have a lot of separate loaders (let's say one for each component, not a single loader for the whole page) and it you use aria-live="assertive" or role="alert" it will be very intrusive and each of the loaders will get called out.




回答3:


Did you try using role="alertdialog" aria-busy="true" on your span?




回答4:


Note that this has also been answered here How do you make the Loading icon accessible for screen-readers like JAWS? with this combo: role="alertdialog" aria-busy="true" aria-live="assertive"



来源:https://stackoverflow.com/questions/38704467/how-to-label-a-loading-animation-for-wai-aria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!