当前位置: 代码迷 >> JavaScript >> js监控浏览器封闭
  详细解决方案

js监控浏览器封闭

热度:82   发布时间:2012-10-24 14:15:58.0
js监控浏览器关闭

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
?<HEAD>
? <TITLE> New Document </TITLE>
? <META NAME="Generator" CONTENT="EditPlus">
? <META NAME="Author" CONTENT="">
? <META NAME="Keywords" CONTENT="">
? <META NAME="Description" CONTENT="">
?</HEAD>
<script type="text/javascript">??
<!--????
??? window.onbeforeunload = onbeforeunload_handler;??
??? window.onunload = onunload_handler;??
??? function onbeforeunload_handler(){??
??????? 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 = ""; //这里可以放置你想做的操作代码???
????????????? }???
?
??? }??
??????
??? function onunload_handler(){??
??????? var warning="谢谢光临";??
??????? alert(warning);??
??? }??
// -->??
</script>??
?<BODY>
?
?</BODY>
</HTML>

  相关解决方案