html - 自禁用按钮,辅助功能

标签 html firefox accessibility wai-aria nvda

有没有办法让 self 禁用按钮不显示“不可用”或“变暗”?

参见示例Example

var saveBtn = document.getElementById("saveBtn");
var helper = document.getElementById("helper");
var content = document.getElementById("content");
saveBtn.onclick = function(e) {
  saveBtn.setAttribute("disabled", "disabled");
  saveBtn.setAttribute("aria-disabled", true);
  content.innerHTML = 'Lorem input a lot of stuffs';
  helper.innerHTML = "Content added, please read it";
  setTimeout(function(){
    helper.innerHTML = "";
    saveBtn.removeAttribute("disabled");
    saveBtn.setAttribute("aria-disabled", false);
  }, 5000);
};
  • 仅语音提示:“内容已添加,请阅读”
  • NVDA 表示:“内容已添加,请阅读。 不可用'

我知道它正在发生,因为按钮仍然具有焦点。但是,我需要找到解决方案,因为我无法修改页面的当前行为。

我正在使用 html 帮助器来通知转换,如您所见 https://stackoverflow.com/a/38137593/3438124 .

抱歉代码丑陋,这只是为了模拟我的真实行为。

谢谢大家!

最佳答案

您需要将焦点移至新元素。给它 tabindex=0,然后使用 focus()

aria-live 适用于当您希望屏幕阅读器朗读具有 aria-live 属性的内容区域的更改时。由于您在同级 div 上使用它,因此您错过了它执行其功能的机会。或者,您可以跳过 tabindex/focus() 方法,只需将 aria-live 放在新内容的容器上。

此外,您可以放弃 aria-disabled 并仅使用 disabled 按钮。 aria-disabled 适用于不支持 disabled 的元素。

关于html - 自禁用按钮,辅助功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39237790/

相关文章:

Applescript 将显示切换到灰度模式

html - 为什么我在缩小一个大框时继续出现滚动条?

javascript - HTML - 如何检查文件(.js 或 .css)是否已加载或从缓存中获取?

debugging - 将特定页面上的所有 http 请求导出到 txt/csv

javascript - onchange() 在 Firefox 中未触发

ios - 将 VoiceOver 设置为忽略 UITextField 中的占位符文本?

辅助功能 - 无法识别 lang html 标签

html - 水平对齐输入字段

javascript - <dialog> 上的焦点陷阱不是绝对的,焦点转移到浏览器 UI 元素

android - Firefox for Android (v18) CSS 重置?