js阻止浏览器关闭
<script lang="typescript/js">
window.isCloseHint = true;
//初始化关闭
window.addEventListener("beforeunload", function(e) {
if (window.isCloseHint) {
var confirmationMessage = "要记得保存!你确定要离开我吗?";
(e || window.event).returnValue = confirmationMessage; // 兼容 Gecko + IE
return confirmationMessage; // 兼容 Gecko + Webkit, Safari, Chrome
}
});
</script>