

javascript - VoiceOver does not react to anchors and changing focus on iOS prope...
source link: https://stackoverflow.com/questions/56598650/voiceover-does-not-react-to-anchors-and-changing-focus-on-ios-properly
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

VoiceOver does not react to anchors and changing focus on iOS properly
I have asked questions like this one before, but I can't find peace of mind until I found a workaround:
VoiceOver on iOS is the only screen reader I encountered which doesn't seem to handle anchors and the JavaScript element.focus()
function correctly.
Check out my blog. There you'll see the classic skip to content
-link and a scroll to top
-button. The link is a regular anchor with its target being the div with the id main
. The button triggers an animation, but as this isn't having the desired ecfect for the blind, I also made it move focus to the skip to content
link. Double tap on either of the aforementioned controls while VoiceOver is switched on. The focus will not get moved. I tested this in the iOS apps for Safari, Firefox, Google Chrome and iSource.
Now go to any other device, be it android phone, or windows computer. Switch a screen reader on. As far as I could tell, it always worked (tested with Microsoft Edge, Google Chrome and Internet Explorer).
The HTML for the anchor:
<a href="#main" id="top-link">Skip to content</a>
<!-- ... -->
<div id="main" role="main">
<!-- ... -->
</div>
The JS for the button: document.getElementById('scroll-to-top').addEventListener('click', function() { document.getElementById('top-link').focus(); });
Nothing fancy, right? And no, tabindex="-1"
on the main div does not fix my anchor problem. What works is if the anchor refers to a link, but there must be some visible text in it, something like
<a id="anchorTarget"> </a>
doesn't work. Did anyone stumble upon a good, solid workaround, or will I just have to live with the fact that my anchors/JavaScript focus changing doesn't do anything for VoiceOver users on iOS?
Recommend
-
7
Header Anchors: A Safari Extension Ever want to link to a specific part of...
-
33
Fixed page header overlaps in-page anchors Join Stack Overflow to learn, share knowledge, and build your career.
-
12
Worldwide Here Are The Female Anchors That Are Dominating The Media World Published on 02/15/2021...
-
10
Accessibility WTF: Voiceover on Mac announcing a list tree as a table? Wednesday, July 28th, 2021 at 9:14 pm I’m currently investigating a strange bug we got reported with t...
-
5
-
6
-
7
by zhangxinxu from http://www.zhangxinxu.com/wordpress/?p=5893 本文可全文转载,但需得到原作者书面许可,同时保留原作者和出处,摘要引流则随...
-
10
How to Use VoiceOver Image Descriptions With Your iPhone Photos By Kaylyn McKenna Published 21 hours ago Follow this guide to a...
-
4
Want to Use VoiceOver in a Different Language? Here’s How to Change It By Hiba Fiaz Published 2 hours ago Follow this simple guide...
-
2
VoiceOver For Frequently Updating Data VoiceOver For Frequently Updating Data A quick tip and reminder if you’re showing something that updates frequently you need to let VoiceOver know. What’s The Problem?
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK