by
clemens
(23.09.2021)
beforeunload Deactivated on iOS
tl;dr
On Safari in iOS the event beforeunload
does not exist, but it does on Safari for MacOS. Add a
global event listener on all clicks on anchor tags as a workaround.
document.addEventListener("click", e => {
if (e.target.tagName == "A") {
if (!confirm("Do you want to exit?")) {
e.preventDefault();
}
}
});