The below code works in FF but in chrome, browser_close_event() is not working. The browser_close_cancel_event() is working though.
The both browser_close_event() and browser_close_cancel_event() functions will fetch ajax call when called.
How can i call a function when user click the 'leave' button in browser close alert.
$( document ).ready(function() {
var oldMousemove = document.body.onmousemove,
onCancel = function () {
// Do something if the user stays.
browser_close_cancel_event();
document.body.onmousemove = oldMousemove;
};
window.onbeforeunload = function() {
// if user click leave
browser_close_event();
document.body.onmousemove = onCancel;
return 'Do you really want to leave?';
};
});