1 2 3 4

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>
posted @ 2021-03-03 16:53  无序  阅读(2725)  评论(0编辑  收藏  举报