doctype (W3C DOM Core property)
var dtd = document.doctype;
In the example above, the dtd variable is a reference
to the Document Type Declaration for this document, which is an instance
DocumentType interface, containing
properties such as the
publicId. So in this next example:
var pubid = dtd.publicId;
If we were on a page
with an XHTML 1.0 Strict doctype, the pubid variable
would have the value
-//W3C//DTD XHTML 1.0 Strict//EN.
The Document Type Declaration
of an XML document. For HTML documents, or XML documents without a
document type declaration, this property should return
This property is readonly.
And if you're lucky, you'll never need this!
In Internet Explorer 6 and 7
and Safari 1.3 and 2 in HTML mode1, the
doctype property returns
However this is according to specification — the
doctype should only return an object in XML
(including XHTML mode2), otherwise it should be
In Safari 1.3 and 2 in XHTML
mode or XML the
doctype property is
available, but all its properties are
Firefox 3 in HTML mode the
name of a
is returned in uppercase.
Internet Explorer 5.5 in
HTML does not implement this interface
doctype is undefined).
The relationship between the
node and its owning
Document varies between
browsers. While all which implement this interface have the correct
Firefox has the document as its
parentNode; in Opera and Safari
3 both properties are
Firefox has the correct behavior.
Opera in XHTML mode or XML and
Internet Explorer in XML return a populated
entities collection; in
Safari and Firefox
null. In Internet Explorer in
XML this collection only includes internal entities (those
defined in a doctype's internal subset).
Only Opera in
XHTML mode and Firefox in XHTML mode or
XML provide data for the
internalSubset property; in
Internet Explorer it's undefined, and in other
browsers and modes it's an empty string.
There are no comments yet.