代码之家  ›  专栏  ›  技术社区  ›  CommonSenseCode

如果aria live被其他标签打断,如何阻止这种行为?

  •  0
  • CommonSenseCode  · 技术社区  · 7 年前

    我现在有一个aria live=assertive的div:

    <div id="accesibility__ready" aria-live="assertive" aria-atomic="true"></div>
    

    目前在我的js文件中,我有一个方法,可以用tabindex(第一个标题)然后 <p>

      var ariaAlert = document.getElementById('accesibility__ready');
      ariaAlert.setAttribute('aria-label','Content updated tab navigation ready'); 
    

    我注意到有时aria live会被阅读,但是它会被所有其他标签(不是aria live)打断,不知怎么的,屏幕阅读器决定阅读。

    那么我该如何阻止aria live被其他标签打断呢?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Community CDub    5 年前

    听起来不像 aria-live 正在正确使用。 阿丽亚现场 如果某个元素的内容/子元素将发生更改,则打算在该元素上使用。这包括添加/删除/更改元素本身的文本(例如 textContent W3 spec on aria-live 完整的细节。

    aira-live 用于指示元素的属性何时更改。也就是说,使用 阿丽亚现场 <div> aria-label 宣布。

    aria-atomic aria-atomic="false" -默认值)还是应该读取整个元素( aria-atomic="true" ).

    <div aria-live="polite">
      this message will self destruct in 
      <span id="counter">X</span> 
      seconds
    </div>
    

    没有 原子的 false 如果您更新 counter 到“5”,然后 计数器的值将显示为“5”。但是,如果您使用 aria atomic=“真” <部门>

    <div aria-live="polite" aria-atomic="true">
      this message will self destruct in 
      <span id="counter">X</span> 
      seconds
    </div>
    

    到'5',您将听到“此消息将在5秒内自毁”。

    aria-live="polite" 除非你有一条非常重要的信息需要打断别人的阅读。很少有这样的情况 aria-live="assertive" 必须使用。使用 assertive

    https://www.w3.org/TR/wai-aria/#aria-live

    “用户代理或辅助技术 五月 选择在发生断言更改时清除排队更改“

    <h2>