JavaScript DHTML/jQuery/unload

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

To display an alert when a page is unloaded:

   <source lang="html4strict">

$(window).unload( function () { alert("Bye now!"); } );

 </source>
   
  


Unload event

   <source lang="html4strict">
   

<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>