IE窗口关闭时如何提交JS事件

  在网页中加入下列代码就知道效果了    
  1、=====================================================
<script type="text/javascript">
window.onbeforeunload = function()
       {   
              var n = window.event.screenX - window.screenLeft;   
              var b = n > document.documentElement.scrollWidth-20;   
              if(b && window.event.clientY < 0 || window.event.altKey)   
              {   
                     openwin();
                     alert('查看弹出');  
                     window.event.returnValue = ""; //这里可以放置你想做的操作代码   
              }   
       }
      
function openwin(){
alert();
//写下事件
}   
</script> 
2、==========================================================
<script type="text/javascript">  
<!--    
    window.onbeforeunload = onbeforeunload_handler;  
    window.onunload = onunload_handler;  
    function onbeforeunload_handler(){  
        var warning="确认退出?";          
        return warning;  
    }  
      
    function onunload_handler(){  
        var warning="谢谢光临";  
        alert(warning);  
    }  
// -->  
</script>

你可能感兴趣的:(IE窗口关闭时如何提交JS事件)