We are trying to prompt the user before leaving a page using onbeforeunload event. I found that the prompt does not appear in Safari iOS Mobile. However, it works fine on Desktop. Any reason or documentation for why it does'nt work on Mobile? Thanks a lot.
Asked
Active
Viewed 1,268 times
1 Answers
1
Maybe a bug on iOS
https://bugs.webkit.org/show_bug.cgi?id=219102
Many searches lead me to this:
window.onbeforeunload and window.onunload is not working in Firefox, Safari, Opera?
But it doesn't seem to be updated and to match actual behaviour. In my case the browser should go back to another website, and none of the events were firing (beforeunload, unload, popstate, pagehide). I did see beforeunload on MacOs safari:
window.addEventListener('beforeunload',function(event) {debugger});
It fired when clicking on links, and even when running: history.back() but not when running history.back() where it switches between domains.

Asaf M
- 274
- 2
- 9