简体   繁体   English

加载页面时,可访问性aria-live无法正常工作

[英]accessibility aria-live not working when loading a page

I am trying to get my screen reader to read the message whenever my page loads with a message. 我试图让我的屏幕阅读器在页面加载消息时阅读消息。 Below is the code that I have used. 下面是我使用的代码。 I could read the message when I hover on the text. 当我将鼠标悬停在文本上时,我可以阅读该消息。 But, for some reason I cannot get the screen reader to read my message on page load . 但是,由于某种原因,我无法让屏幕阅读器读取页面加载时的消息。 Please suggest if there is something that I need to do. 请提出我是否需要做的事情。

<div class="bannerError">
    <div class="bannerError_image"></div>
    <span class="bannerError_text" aria-live="assertive">Please enter your name
    </span>
</div>

The live region container must be present in the HTML at the time of page load, however it should not contain any content initially. 活动区域容器在页面加载时必须存在于HTML中,但是最初不应包含任何内容。

Only after the page has loaded will the contents of the live region be monitored for updates. 仅在页面加载后,才会监视活动区域的内容以进行更新。 Adding content to the live region is typically accomplished via JavaScript. 通常,通过JavaScript将内容添加到实时区域。

You may want to take a look at the WCAG page for aria-live usage: W3C - Using ARIA role=alert or Live Regions to Identify Errors 您可能想看看咏叹调实时使用的WCAG页面: W3C-使用ARIA role = alert或实时区域来识别错误

Also, Terril Thompson has a pretty good live region testing page that illustrates some of the different ways that aria-live can be implemented. 此外,Terril Thompson的现场区域测试页面也非常不错,该页面说明了实现aria-live的一些不同方式。

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

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