解析javascript 浏览器关闭事件
代码如下:
<script type="text/javascript">
windowonbeforeunload = onbeforeunload_handler;
windowonunload = onunload_handler;
function onbeforeunload_handler(){
var warning="确认退出?";
return warning; //可以换成alert等具体操作
}
function onunload_handler(){
var warning="谢谢光临";
alert(warning); //关闭后执行
}
</script>