Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
Web Accessibility. window.speechSynthesis vs role "alert"

To immediately announce error for control/input I have 2 choices:

  1. append HTMLElement to document with role 'alert' and error-message. NVDA reads alert. [errorMessageHere]

const el = document.createElement('div');
el.setAttribute('role', 'alert');
el.className = 'visually-hidden';
el.textContent = 'Some message here';
document.body.append(el);
.visually-hidden {
  position: absolute;
  height: 1px;
  width: 1px;
  top: 0;
  left: 0;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
}

  1. Use window.speechSynthesis.speak. NVDA announce [errorMessageHere]

const speakObj = new SpeechSynthesisUtterance('Some message here');
window.speechSynthesis.speak(speakObj)

What I really notice that in NVDA you can disable text-to-speech and show speech-viewer. First case will be logged into speech-viewer but 2nd case - not. NVDA directly announce text when NVDA is opened even if text-to-speech is disabled.

I'd prefer to use window.speechSynthesis.speak instead of creating extra HTMLElements per each case when some details/errors must be announced but I'm not sure is it correct alternative of role 'alert' since window.speechSynthesis.speak is not logged by NVDA at all (but only announced).

Could help me to understand what the best way to be announced/read by screen reader ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda