js 監控瀏覽器關閉事件

代碼以下:javascript

<!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>