Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* iOS doesn't support beforeunload, use pagehide instead.
* NOTE: I tried doing this detection via examining the window object
* for onbeforeunload/onpagehide, but they both exist in iOS, even
* though beforeunload is never fired.
var iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0;
var eventName = iOS ? 'pagehide' : 'beforeunload';
window.addEventListener(eventName, function (event) {
// Do the work...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.