[asp.net]页面关闭时触 发事件


页面关闭时触 发事件


1
<script language="javascript">
2 window.onbeforeunload = function()
3 {
4 if(!(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey))
5 {
6 //在刷新、或以_self方式转到其它页面、或用ALT+CTLR+DEL关闭时触发;
7 //代码
8 }
9 else
10 {
11 //点击工具栏上的[X]按钮、或ALT+F4关闭时触发
12 }
13 }
14 </script>

 

 1 window.onbeforeunload  =  function()   
2 {
3 if((event.clientX>document.body.clientWidth&&event.clientY<0)||event.altKey)
4 {
5 //alert("关闭触发");
6 }
7 else
8 {
9 //alert("刷新触发");
10 }
11 }



posted @ 2012-04-06 14:45  天涯行客  阅读(712)  评论(0编辑  收藏  举报
天道酬勤--埋头静默--厚积薄发