on browser tab close js popup message code example
Example 1: js ask before close
window.onbeforeunload = function() {
return "";
}
Example 2: javascript confirm tab close
<script>
window.onbeforeunload = function (e) {
e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
e.returnValue = 'Sure?';
}
// For Safari
return 'Sure?';
};
</script>