all

자바스크립트 삽입 태그

알 수 없는 사용자 2010. 3. 5. 16:02

<script type="text/javascript">
<!--
// This will write a header: - 싱글라인 코멘트
document.write("<h1>This is a header</h1>");
document.write("Hello"); // This will write "Hello" - 주석을 끝에 달 수도 있다.

document.write("<p>This is a paragraph</p>");

/*
The code below will write
one header and two paragraphs
*/ - 멀티 라인 코멘트
document.write("<p>This is another paragraph</p>");

//document.write("<p>This is another paragraph</p>"); 임시로 사용하지 않을 경우 - 싱글라인

/*
document.write("<h1>This is a header</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is another paragraph</p>");
*/ 임시로 사용하지 않을 경우 - 멀티라인
{
document.write("<h1>This is a header</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is another paragraph</p>");
} 그룹지을 수 있다.


//--> 만약 자바스트립트를 지원하지 않는 브라우저에서 자바스크립트 코드가 보이지 않도록 주석태그로 감싼다.
</script>

 

<script type="text/javascript" src="xxx.js"></script> 자바스크립트 외부로 빼서 작업하기