목차
document.doctype 예제 - 현재 웹문서의 DTD 정보 반환
document.doctype 정의
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
주소 복사
랜덤 이동