I am using following code which shows me an alert on closing. It is working fine on desktop but,It is not showing any messages on closing in mobile.I have used chrome,mozilla and safari but it's not working.Is there any other way to do this?
var timeout;
function warning() {
timeout = setTimeout(function() {
alert('You are leaving the page 111111111111');
}, 500);
return "You are leaving the page";
}
function noTimeout() {
timeout = setTimeout(function() {
alert('2222222222');
},10);
clearTimeout(timeout);
}
window.onbeforeunload = warning;
window.unload = warning;
window.unload = warning;