How to use JQuery Event unload() Method

This article describe about jQuery Event unload() Method.
  • 2447

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.






<!DOCTYPE html>



<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $(window).unload(function () {







<p>When you click <a href="">this link</a>, or close the window, an alert box will be triggered.</p>






unload method pic1.jpg


Note: In the above show output hyperlink used if you click on this link then trigger generate and open the 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


More Articles

© 2020 DotNetHeaven. All rights reserved.