js 监控浏览器关闭事件

China☆狼群 提交于 2019-12-23 14:20:18

代码如下:

<!DOCTYPE html>
<html>
    <head>
        <title>监控浏览器关闭事件</title>
    </head>
    <style type="text/css">
    </style>
    <body>
        <div id="create_order">
        </div>
    </body>
</html>
<script type="text/javascript">
    var widowClose = {};
    widowClose.tip = "浏览器即将关闭,是否确定??";
    widowClose.set = function(a) {
        window.onbeforeunload = function(b) {
            b = b || window.event;
            b.returnValue = a;
            return a
        }
    };
    widowClose.clear = function() {
        fckDraft.delDraftById();
        window.onbeforeunload = function() {
        }
    };
    widowClose.set(widowClose.tip);
</script>

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!