if (window.attachEvent) {

    /*IE and Opera*/

    window.attachEvent("onunload", function() {

        /* ......?!@# */

    });

} else if (document.addEventListener) {

    /*Chrome, FireFox*/

    window.onbeforeunload = function() {

        /* ......?!@# */

    };

    /*IE 6, Mobile Safari, Chrome Mobile*/

    window.addEventListener("unload", function() {

        /* ......?!@# */

    }, false);

} else {

    /*etc*/

    document.addEventListener("unload", function() {

        /* ......?!@# */

    }, false);

}


출 처 : http://plibet.blogspot.kr/2013/09/javascript-unload.html




+ Recent posts