jQuery Show Alert Message before Leaving (Closing) from Web Page
Introduction:
Here I will explain how to use jQuery to show alert message before leaving from web page or jQueryshow alert message while leaving from web page or closing web page using beforeunload method.
Description:
In previous articles I explained jQuery open all external links in new window, jQuery enable / disable controls on page, jQuery enable or disable hyperlinks, jQuery Countdown timer script example, jQuery Increase or Decrease font size of website and many articles relating to JQuery and asp.net. Now I will explain how to use jQuery to show alert message before leaving from web page.
In previous articles I explained jQuery open all external links in new window, jQuery enable / disable controls on page, jQuery enable or disable hyperlinks, jQuery Countdown timer script example, jQuery Increase or Decrease font size of website and many articles relating to JQuery and asp.net. Now I will explain how to use jQuery to show alert message before leaving from web page.
To show alert message while leaving from webpage we need to write the code like as shown below
|
Example
<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