关闭页面触发事件

下面这段代码可以在页面关闭的时候自定义信息提示你

<html>
<head>
<title></title>
<script type="text/javascript">

function ConfirmClose() {
window.event.returnValue
= "请先保存好数据";
}

function ShowConfirmClose(blnValue) {
if(blnValue) {
document.body.onbeforeunload
= ConfirmClose;
}
else {
document.body.onbeforeunload
= null;
}

}
</script>
</head>
<body onload="ShowConfirmClose(true)">
</body>
</html>
posted @ 2011-04-21 22:28  poisson_notes  阅读(623)  评论(0编辑  收藏  举报