Here I will explain how to use jQuery to show alert message before leaving from web page or jQuery show alert message while leaving from web page or closing web page using beforeunload method.
<script type="text/javascript">
$(function() {
$(window).on('beforeunload', function() {
return '';
});
});
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Show Alert Message while leaving from webpage</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$(window).on('beforeunload', function() {
return '';
});
});
</script>
</head>
<body>
<form id="form1">
<div>
<b>Welcome to Aspdotnet-suresh.com</b>
</div>
</form>
</body>
</html>
No comments:
Post a Comment