문제

Is the doctype part of the DOM, and if so, is there a good cross-browser way to read it? I'm not trying to do anything fancy. I just want to access the doctype information from within some JavaScript code. Read-only access is fine.

도움이 되었습니까?

해결책

document.doctype seems to be the (read-only) property you're looking for.

다른 팁

If you're inspecting the DOCTYPE to determine if you're in quirksmode or not, this is known to be cross-browser:

document.compatMode; // returns either "BackCompat" or "CSS1Compat"

So you can do:

var quirksmode = document.compatMode == "BackCompat";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top