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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM