I found a lot of code to detect the close button of browsers, but I got an event when a closed tab was called. I just want the main event of the close button to alert the user to stay on this page or not. I found this code.
<script type="text/javascript">
window.onbeforeunload = function (evt){
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
} return message;
}
</script>
It warns that users close or stay by closing the tab.
Now I want to detect the closing event of the main browser. Since the found closed event is also used to close tabs.
Can someone help me on this issue?
source
share