Element: ariaLive 屬性

Baseline 2023
新推出

自 ⁨2023 年 10 月⁩ 以來,此功能已在最新裝置和瀏覽器版本中得到支援。此功能可能無法在舊裝置或瀏覽器上執行。

Element 介面的 ariaLive 屬性反映了 aria-live 屬性的值,該屬性指示元素將要更新,並描述了使用者代理、輔助技術和使用者可以從 即時區域 獲得的更新型別。

一個字串,其值可能為以下之一:

"assertive"

表示該區域的更新具有最高優先順序,應立即呈現給使用者。

"off"

表示除非使用者當前聚焦在該區域,否則不應向用戶呈現該區域的更新。

"polite"

表示該區域的更新應在下一次合適的機會呈現,例如在說完當前句子時或使用者暫停輸入時。

示例

在此示例中,ID 為 planetInfo 的元素的 aria-live 屬性設定為 "polite"。然後,我們將該值更新為 "assertive"

html
<div role="region" id="planetInfo" aria-live="polite">
  <h2 id="planetTitle">No planet selected</h2>
  <p id="planetDescription">Select a planet to view its description</p>
</div>
js
let el = document.getElementById("planetInfo");
console.log(el.ariaLive); // "polite"
el.ariaLive = "assertive";
console.log(el.ariaLive); // "assertive"

規範

規範
無障礙富網際網路應用程式 (WAI-ARIA)
# dom-ariamixin-arialive

瀏覽器相容性