离开页面前调用Js方法

<html xmlns= "[url]http://www.w3.org/1999/xhtml[/url]" >
  <head>
  <meta http-equiv= "Content-Type"  content= "text/html; charset=gb2312"  />
  <title>onbeforeunload测试</title>
  <script>
  function checkLeave(){
         event.returnValue= "确定离开当前页面吗?" ;
  }
  </script>
  </head>
  <body onbeforeunload= "checkLeave()" >
  </body>
  </html>

你可能感兴趣的:(JavaScript,表单)