아래처럼 하고 페이지를 로딩하면 'window onload' -> '3' -> '2' -> '1' 순으로 출력된다.
onload 가 일단 호출되고, 뒤에 건 이벤트가 먼저 호출되는 성격.
이벤트가 stack으로 쌓이는 모양.



<script>
function start() { alert('1'); }
function start2() { alert('2'); }
function start3() { alert('3'); }

if (window.attachEvent) window.attachEvent('onload', start);
else                            window.addEventListener('load', start, false);

if (window.attachEvent) window.attachEvent('onload', start2);
else                            window.addEventListener('load', start2, false);

if (window.attachEvent) window.attachEvent('onload', start3);
else                            window.addEventListener('load', start3, false);
 
window.onload = function () {
    alert('window onload');
}
</script>

'JavaScript' 카테고리의 다른 글

선 그리기 (Line Drawing)  (0) 2009.06.09
ext.js 가 동작하지 않을 경우  (0) 2009.05.20
onclick 한꺼번에 걸기  (0) 2009.05.02
insertAfter 함수  (0) 2009.05.02
DOM Node Property  (0) 2009.05.02
Posted by bloodguy
,