开发者

Read doctype with JavaScript

开发者 https://www.devze.com 2022-12-15 09:20 出处:网络
Is the doctype part of the DOM, and if so, is there a go开发者_如何学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 so

Is the doctype part of the DOM, and if so, is there a go开发者_如何学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";
0

精彩评论

暂无评论...
验证码 换一张
取 消