DOM

Document.doctype プロパティ

 編集:2022.09.01 by T.A.

Document の文書型宣言(DTD)を返します。

文書型宣言(Document Type Declaration:DTD)を返します。返されるオブジェクトは、DocumentType インターフェイスを持ちます。DocumentType を生成するには DOMImplementation.createDocumentType()を使用してください。

構文
Document.doctype

DocumentType

現在の文書に関連付けられている DTD が存在しないは null が返されます。

DOM レベル 2 では、文書型宣言の編集に対応していません。

var doctypeObj = document.doctype;

console.log(
  "doctypeObj.name: "           + doctypeObj.name            + "\n" +
  "doctypeObj.internalSubset: " + doctypeObj.internalSubset  + "\n" +
  "doctypeObj.publicId: "       + doctypeObj.publicId        + "\n" +
  "doctypeObj.systemId: "       + doctypeObj.systemId
);

テスト