Skip to content

Instantly share code, notes, and snippets.

@ozknozsrt
Created September 5, 2023 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozknozsrt/49d913d0f30aaf305c9a6c7908978fce to your computer and use it in GitHub Desktop.
Save ozknozsrt/49d913d0f30aaf305c9a6c7908978fce to your computer and use it in GitHub Desktop.
window-onbeforeunload-not-working-on-the-ipad
// https://stackoverflow.com/questions/3239834/window-onbeforeunload-not-working-on-the-ipad
if (typeof (onbeforeunloadCallBack) === "function") {
//newWindow.onbeforeunload = function (param) {
// onbeforeunloadCallBack(param);
//}
var isOnIOS = navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i);
var eventName = isOnIOS ? "pagehide" : "beforeunload";
newWindow.addEventListener(eventName, function (param) {
console.log("eventName", eventName);
console.log("param", param);
onbeforeunloadCallBack(param);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment