请问下,关闭浏览器或输入别的网址离开这个页面时才触发的js函数是什么??

解决方案 »

  1.   

    没人回答,我自己回答
    <SCRIPT>
    function closeIt()
    {
    event.returnValue = "";
    }
    </SCRIPT>
    <BODY onbeforeunload="closeIt()">
    <a href="www.这样啊.com">Click</a>
    </BODY>
      

  2.   

    <script language="javascript">
    window.onbeforeunload = function()  //author: meizz
    {
      var n = window.event.screenX - window.screenLeft;
      var b = n > document.documentElement.scrollWidth-20;
      if(b && window.event.clientY < 0 || window.event.altKey)
        {
            alert("是关闭");
      //  window.event.returnValue = "www";  //这里可以放置你想做的操作代码
        }
      else
        {
         alert("是刷新");
        }}
    </script>