Tried to call browser tab close event when click on close tab icon in chrome browser but not working.I want to show alert message before close the browser tab.How do it?
Below code is not working:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<script type="text/javascript">
window.onbeforeunload = function(evt) {
var message = "Are you sure?";
/* InternetExplorer/Firefox*/
var e = evt || window.event
e.returnValue = message
/* WebKit browser */
return message;
}
</script>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>