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)   
  {   
        alert(
"正在关闭页面!");
  }   
}   
</script> 

 

上面的代码可以捕获点击IE的关闭按钮和Alt+F4的事件,但是如果标题栏或者是任务栏中点右键,选择关闭按钮的话,捕获不到

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2021-11-27
  • 2021-09-09
  • 2021-08-04
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案