• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Document] JS - document.doctype 속성 -문서타입 (= DTD정보 = DocumentType 객체 반환 = 다큐먼트독타입 속성)

목차

  1. document.doctype 예제 - 현재 웹문서의 DTD 정보 반환
  2. document.doctype 정의
  3. document.doctype 구문

 

document.doctype 예제 - 현재 웹문서의 DTD 정보 반환

 

<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.doctype.name;

  document.getElementById("demo").innerHTML = x;

}

</script>

 

결과값: html

 

document.doctype 정의

 

HTML 문서의 doctype을 DocumentType 객체로 반환.

 


 

1.

DocumentType 객체엔 다양한 서브 속성 존재. (예: name)

 

  • document.doctype.name - DOMString (예) <!DOCTYPE HTML> 의 경우 "html"

 

2.

문서에 지정된 doctype 없는 경우 null 반환.

 

3.

모든 주요 브라우저 모두 지원.

단, IE8과 그 이전 버전은 HTML 및 XHTML은 null 반환. (오직, XML 문서에 대해서만 작동.)

 

4.

DOM 버전: Core Level 1 Document Object

 

5.

MDN document.doctype 예제 보기

 

 

document.doctype 구문

 

document.doctype

 


방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
게시물이 없습니다.
목록
찾아주셔서 감사합니다. Since 2012