关闭页面触发事件

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

<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>
原文地址:https://www.cnblogs.com/poissonnotes/p/2024315.html