앙되요

ie9 창닫힐 때 onunload 이벤트 안먹는 문제. 본문

Ajax & Javascript & JSP

ie9 창닫힐 때 onunload 이벤트 안먹는 문제.

앙되요 2011. 10. 17. 15:24
출처 : http://computerhelpforums.net/topic/35277-internet-explorer-same-markup-writing-cross-browser-code/

// [TR] Different listeners added for illustration function f1() { document.write("addEventListener was used"); } function f2() { document.write("attachEvent was used"); } // Use this: Feature Detection if(window.addEventListener) { window.addEventListener("load", f1, false); } else if(window.attachEvent) { window.attachEvent("onload", f2); }
Try It!

IE9 Output: addEventListener was used


저런식으로 하면 된다지만..

사실. onunload는 여전히 안먹는다.

결국

브라우저의 셋팅을 만저주어야만 사용가능하다.

ie7,ie8은 onunload가 enable, ie9는 disable로 되어 있어서 그렇다

IN IE 9 browser  shut down behavior is disabled, that means that window.onunload event won't fire. In all browsers except IE9 this behavior is enabled by default.http://www.grouppolicy.biz/2011/03/internet-explorer-9-group-policy-settings/