onbeforeunload:网页关闭(跳转到别的网页,刷新本页)事件前发生。可以选择继续或者停止动作。
onunload:网页关闭(跳转到别的网页,刷新本页)事件的同时发生,不能停止动作。
<script>
function checkQuit()
{
event.returnValue = "Are you sure to leave?";
}
function alertQuit()
{
alert("Welcome for next time.");
}
</script>
<body οnbefοreunlοad="checkQuit();" οnunlοad="alertQuit();"></body>
IE肯定支持,但是我本机的谷歌和火狐不支持。