<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Confirm Before Leave</title>
<script language="javascript" type="text/javascript">
<!--
var pb_strConfirmCloseMessage;
var pb_blnCloseWindow = false;
pb_strConfirmCloseMessage ="您真的要离开本页吗?";
function ConfirmClose() {
window.event.returnValue = pb_strConfirmCloseMessage;
pb_blnCloseWindow = true;
}
function ShowConfirmClose(blnValue) {
if(blnValue) {
document.body.onbeforeunload = ConfirmClose;
} else {
document.body.onbeforeunload = null;
}
}
//--></script>
</head>
<body onload="ShowConfirmClose(true);">
<input type=button value="提示" onclick="ShowConfirmClose(true);">
<input type=button value="不提示" onclick="ShowConfirmClose(false);">
<input type=button value="测试刷新" onclick="window.location.reload();">
</body>
</html>
本文来源【学网】网站链接是http://www.xue5.com