简体   繁体   中英

Read customized message when content updates for aria-live

If I have an element that has the aria-live='polite', but I don't want the screen reader to reads the updated content, but a customized message I provide, is it possible?

Thanks!

Adding content to a live region when you don't want it announced goes against the design of the ARIA live region specification , so I'd encourage you to think this through before proceeding with whatever you're doing here, but for purposes of this question I'm going to focus purely on what is and isn't technically possible.

You could, in theory, add aria-hidden="true" to the content in the live region that you don't want announced. This will prevent this section of the DOM from being exposed to the accessibility tree in the browser. At the same time, this content will be visible to sighted visitors.

On the flipside, you can add content to a live region that isn't visible to sighted users. This would be the "custom message" that you describe. The usual technique for this would be to position the content off-screen using CSS .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM