Warm tip: This article is reproduced from serverfault.com, please click

Aria-Live in Firefox not read by screen reader

发布于 2019-09-03 08:30:41

I am having an issue where the Screen Reader is not reading the text that changes within aria-live section in FireFox.

This is a simple example for a page where in chrome the Screen Reader reads the changes as they come in and in FireFox it does not:

<div aria-live="assertive" id="moo">

</div>
<script>
  let i = 0;
  setInterval(() => {
    document.getElementById('moo').innerText = 'moo' + i++
  }, 2000)
</script>

Am I doing something wrong? Is there another way to announce changes when they come in besides for aria-live that people use with Firefox?

I tested on Mac-Firefox-VoiceOver (it works on Mac-Chrome-VoiceOver)

Questioner
Nachshon Schwartz
Viewed
0
Alessia 2020-11-30 14:40:25

Current firefox version: 83.0 (64-bit)
Firefox Nightly version:85.0a1 (2020-11-29) (64-bit)
In the latest Nightly version, the combination of aria-live on firefox + voiceOver is fixed! 🎉 Hooray!

Reference: Firefox/Voiceover: aria-live regions not being announced

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Aria-live Demo</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <style>
    body {
  margin: 1em;
}

button {
  margin-top: 1em;
  display: block;
}
  </style>
</head>
<body>
  <h1>Aria-live Demo</h1>
  <p>Testing <code>aria-live</code><br><button>Add Content</button><button id="add-more" >Add more content</button></p>

  <!-- add aria-live="polite" -->
  <div class="target" aria-live="polite" ></div>
 
  <script type="text/html" id="test-content">
    <h2>Custom Content</h2>
    <p>Hello there! I am content that is going to be plunked into a container via javascript</p>
  </script>

  <input placeholder="messgae somebody"/>
<script>
$("button").on("click", function(){
  $(".target").html($("#test-content").html());
});

$("#add-more").on("click", function(){
  $(".target").append("<p>Hello World</p>");
});

$(document).on("keydown", function(e){
  // press space to add content
    if(e.keyCode === 32) {
        $(".target").append("<p>Hello World</p>");
    }
});

</script>
</body>
</html>