How to use JQuery Event unload() Method
This article describe about jQuery Event unload() Method.
jQuery Event unload() Method
When user want to navigate away from the current page then unload event occur.
It is generate trigger when
- clicked on the link for leave the page
- Typed new URL in address bar
- Button are used for forward or backward
- Window of browser closed
- Reload the page.
Unload() method only used for window object.
Syntax
$(selector).unload(function)
|
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(window).unload(function () {
alert("Goodbye!");
});
});
</script>
</head>
<body>
<p>When you click <a href="">this link</a>, or close the window, an alert box will be triggered.</p>
</body>
</html>
|
Output
Note: In the above show output hyperlink used if you click on this link then trigger generate and open the dotnetheaven.com main page.
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here