<HTML> <HEAD> <title>test
</title> </HEAD> <body onbeforeunload=
"RunOnBeforeUnload()" onunload=
"RunOnUnload()"> <script language=
"javascript"> function RunOnBeforeUnload() {
window.event.returnValue =
'关闭浏览器将退出系统.'; //alert("before"); } function RunOnUnload() { //执行你的代码 alert("good"); }
</script> </body> </HTML>