html


<script>

alert("script");

</script>


html이 script보다 앞에 있음에도 script가 먼저 실행되어 alert 창이 뜨고 html이 출력된다. 

자바스크립트를 먼저 다 읽고 그 다음 html코드를 읽는 것으로 생각된다. 


<body onload="onloadfunc()">


<script>


function onloadfunc() {

alert("OnloadFunc");

}


alert("script");


</script>


</body>


이 코드도 script가 먼저 뜨고 나중에 onloadfunc가 뜬다.


+ Recent posts