Skip to content

Instantly share code, notes, and snippets.

@RJGrunau
Created May 12, 2021 14:57
Show Gist options
  • Save RJGrunau/6c02b25df0fbd5d316a07a0862258cc2 to your computer and use it in GitHub Desktop.
Save RJGrunau/6c02b25df0fbd5d316a07a0862258cc2 to your computer and use it in GitHub Desktop.
Handling VoiceOver focus on an iOS device while using safari
function setVoiceOverFocus(element) {
var focusInterval = 10; // ms, time between function calls
var focusTotalRepetitions = 10; // number of repetitions
element.setAttribute('tabindex', '0');
element.blur();
var focusRepetitions = 0;
var interval = window.setInterval(function() {
element.focus();
focusRepetitions++;
if (focusRepetitions >= focusTotalRepetitions) {
window.clearInterval(interval);
}
}, focusInterval);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment