The idea is to show a customized popup / div when user closes the browser. Found this code online and it works for me partially.
JS:
window.onbeforeunload = function (e) {
e = e || window.event;
if (e) {
e.returnValue = '';
$("#popup").show();
}
}
HTML:
<div id="popup" class="popup">
</div>
When user closes the browser, an alert pops up with a confirmation, to leave or stay. Is it possible to show the popup/div without showing the default JS alert.
This piece of code also fires when user refreshes the page. How to allow this only on close event.