I have the following code on a page:
var i = 0;
window.addEventListener("focus", function(event) {
document.body.innerHTML = "Focus count = " + i++;
}, false);
On desktop this increments correctly (1,2,3 etc) when switching tabs (or any window blurring/focusing action)
However, when I switch tabs on ios safari the event appears to be firing twice (1,3,5,7 etc)
Why is this happening?
ATTOW the reason is unknown, but this is a known issue in Webkit:
https://bugs.webkit.org/show_bug.cgi?id=179990
From above:
With two or more text inputs on a form, switching focus by click from one to another sometimes causes an extra focus/blur to fire.
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.