js实现页面刷新、关闭、转向时弹出警告

[javascript][/javascript] view plaincopyprint?

  1. $(document).ready(function(){
  2.        var mark = false;
  3.         $(“#form”).change(function(){
  4.              mark = true;
  5.         });
  6.         window.onbeforeunload = function(){
  7.           if(mark){
  8.              return(“您的表单已修改,尚未保存!”);
  9.           }
  10.        }
  11. });

二、onUnload()

[javascript][/javascript] view plaincopyprint?

  1. <body onunload=”alert(‘内容已经修改!’)”>
  2. </body>

说明:  

[javascript][/javascript] view plaincopyprint?

  1. <script language=javascript>
  2.       function window.onbeforeunload(){
  3.       if(event.clientX>document.body.clientWidth && event.clientY<0||event.altKey){
  4.              window.event.re