recently i am working on a project features that show a confirm box when the user decides to close or refresh the page.
I have done this :
window.onbeforeunload = function (e) {
return "Are you sure you want leave?";
};
but it's not working on ios chrome/safari browser and does detect only the refresh on chrome android browser.
I have made some research and i found this on MDN web docs
To combat unwanted pop-ups, some browsers don't display prompts created in beforeunload event handlers unless the page has been interacted with; some don't display them at all. For a list of specific browsers, see the Browser_compatibility section.
anyone have any idea how to deal with this please. Thanks.
UPDATE: After further research i found my question already answerd here How to make a cross-browser on-window-unload request?