js 监控浏览器关闭(完美兼容chrome & ie & fire fox)

阅读更多

转自:http://blog.csdn.net/outlook008/article/details/8763035

 

var UnloadConfirm = {};

UnloadConfirm.MSG_UNLOAD = "数据尚未保存,离开后可能会导致数据丢失\n\n您确定要离开吗?";

UnloadConfirm.set = function(a) {

    window.onbeforeunload = function(b) {

        b = b || window.event;

        b.returnValue = a;

        return a

    }

};

UnloadConfirm.clear = function() {

    fckDraft.delDraftById();

    window.onbeforeunload = function() {

    }

};

UnloadConfirm.set(UnloadConfirm.MSG_UNLOAD);

你可能感兴趣的:(js 监控浏览器关闭(完美兼容chrome & ie & fire fox))