简体   繁体   中英

beforeunload event not triggering in IOS Devices

When user leave page without saving at that time i am using beforeunload to show popup that if you leave then your changes may not be saved so user can choose Leave or Stay but it is not triggering in IOS Device (Iphone, Ipad) so I am stuck in IOS devices.

var isSkipUnsavedChangePopup = false;
    window.addEventListener("beforeunload", function (e) {
        var confirmationMessage = "Are you sure want to leave?";
        if (!$("#btnSave").prop("disabled") && !isSkipUnsavedChangePopup) {
            (e || window.event).returnValue = confirmationMessage;
            return confirmationMessage;
        }
    });

Use unload of jquery mobile this way

$(window).unload(function() {
  alert('Handler for .unload() called.');
});

here is doc: https://demos.jquerymobile.com/1.0a2/experiments/api-viewer/docs/unload/index.html

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM