JavaScript Tutorial/jQuery/unload

Материал из Web эксперт
Перейти к: навигация, поиск

30. To display an alert when a page is unloaded:

   <source lang="javascript">

$(window).unload( function () { alert("Bye now!"); } );</source>


30. Unload event

   <source lang="javascript">

<html>

 <head>
   <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
   <script type="text/javascript">
       $(document).ready(function(){
       
           $(window).unload( function () { alert("Bye now!"); } );
       });
   </script>
 </head>
 <body>
   <body>
   <form action="javascript:alert("success!");">
         <input type="text" />
         <input type="submit" />
    </form>
   </body>

</html></source>