I have added a event listener for when the user tries to leave the page with beforeunload.
window.addEventListener('beforeunload', function (e) {
var message = ' You have not saved your changes. ', e = e || window.event;
if (e) {
e.returnValue = message;
}
return message;
});
The problem I'm having it's with IOS devices ( mobile safari). I know beforeunload is not supported in safari. How will I fire a similar popup in IOS? I've tried pagehide but it's not launching the confirm popup also.