accessibility - 复杂的 aria-live 计时器进度条焦点完成加载和消息问题
问题描述
我想专注于更改页面上的内容。我想为此使用 aria-live,但我不明白为什么它不起作用。为了弄清楚,我将其缩小到一个跨度:
<span class="message" aria-live="polite">Text 1</span>
我运行一行 jQuery 来更改文本:
$('.message').text('Text 2');
在加载条达到 100% 后调用上述行。完整代码:
/* @ -- Progressbar */
var timerCount = 0;
var lastCount = false;
var waitingTime = 10000; //ms
var waitingDevide = 100 / waitingTime;
function loadCalc() {
if (timerCount <= waitingTime) {
if (timerCount !== 0) {
/* @ ---- If not first call */
var currentPercentage = Math.round(timerCount * waitingDevide);
$('.waiting-progressbar-bar').css({width: currentPercentage + "%"});
$('.waiting-progressbar').attr('aria-valuenow', currentPercentage);
if (currentPercentage === 100) {
/* @ ------ When loading is done */
finishedLoading();
}
}
if (timerCount < waitingTime - 1000) {
/* @ ---- Create Random Time for Realistic loader */
var randomInterval = Math.floor(Math.random() * 11) * 100;
/* @ ---- Call Function After Random Time */
setTimeout(loadCalc, randomInterval);
/* @ ---- Add Random Number to Counter */
timerCount = timerCount + randomInterval;
} else if (timerCount !== waitingTime) {
var lastStep = waitingTime - timerCount;
timerCount = timerCount + lastStep;
setTimeout(loadCalc, lastStep);
}
}
}
loadCalc();
function finishedLoading(){
$('.message').text('Text 2');
}
我用上面的代码做了一个jsFiddle:https ://jsfiddle.net/studiovds/czdug5yn/14/show
在我的 OSX Voiceover 屏幕阅读器上运行它不会大声读出更改的内容?
解决方案
推荐阅读
- google-analytics - 检索一个产品的多个 Google Analytics 行是产品范围的 customDimension 值在 Google Big Query 中不同
- python - 如何让用户创建任意数量的字典
- java - 如果数组具有重复的元素,则在Java中进行2路合并
- c# - EF Core 3.1 调用 context.Add() 在使用 SQL 中的序列的模型上抛出“可为空的对象必须有一个值”
- python - 从文本文件中读取某一行并仅打印该行的一部分
- laravel - 如何使用 Laravel 显示数据库通知?
- json - 在列表中显示列表中的控件信息
- react-native - 在 android 上反应原生滚动视图。滚动时,子项与边框半径重叠
- node.js - MongoDB 4.2:仅当它是虚假的时才通过 id 查找并更新另一个字段(布尔值),并确定空响应的原因
- computer-science - TEXT 段和 .text 段之间的区别