js判断页面关闭的方法

 

1、<script language="javascript">

window.onbeforeunload = function()

{

 if(((event.clientX > document.body.clientWidth - 43) && (event.clientY < 23)) || event.altKey) {

  window.event.returnValue = '关闭。';   

 }

}

</script>

2、<script language="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)

{

alert("是关闭而非刷新");

window.open(this.location); 

//return false;

//window.event.returnValue = ""; }

}

</script>


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ajaxchen_615/archive/2009/07/06/4325917.aspx

你可能感兴趣的:(js判断页面关闭的方法)