I have a requirement where when we close the tab or close the browser
I need to perform some processes
. When user will close the tab, there should be no popup
getting displayed. I should be able to directly trigger the Leave
button of the popup
. The code which I am using sometimes work and sometimes not. Is it possible to close the tab or browser without popup or the popup
is mandatory. Please advise. Below is my code :-
Without Popup(sometimes work and sometimes not)
window.onbeforeunload = function() {
//debugger;
perform();
};
//With this i get a popup which I don't want
window.addEventListener("beforeunload", function (e) {
perform();
(e || window.event).returnValue = null;
return null;
});