js监听浏览器关闭事件
html :
<HTML>
<HEAD>
<title>test</title>
</HEAD>
<body onbeforeunload="RunOnBeforeUnload()" onunload="RunOnUnload()">
<script language="javascript">
function RunOnBeforeUnload() {
window.event.returnValue = '关闭浏览器将退出系统.';
}
function RunOnUnload() {
//执行你的代码
}
</script>
</body>
</HTML>
说明:
点击关闭浏览器按钮会出现 提示 “'关闭浏览器将退出系统” 点击确定离开后执行 RunOnUnload()方法
这里实用body的两个事件配置
邮箱:wangh_2@sina.com