このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

DOMImplementation: createDocumentType() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

DOMImplementation.createDocumentType() メソッドは DocumentType オブジェクトを返します。これは文書作成時に DOMImplementation.createDocument で使用したり、Node.insertBefore()Node.replaceChild() などのメソッドで文書中に置いたりすることができます。

構文

js
createDocumentType(qualifiedNameStr, publicId, systemId)

引数

qualifiedNameStr

修飾名の入った文字列です。例えば svg:svg です。

publicId

PUBLIC 識別子の入った文字列です。

systemId

SYSTEM 識別子の入った文字列です。

返値

DocumentType です。

js
const dt = document.implementation.createDocumentType(
  "svg:svg",
  "-//W3C//DTD SVG 1.1//EN",
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);
const d = document.implementation.createDocument(
  "http://www.w3.org/2000/svg",
  "svg:svg",
  dt,
);
alert(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN

仕様書

Specification
DOM
# ref-for-dom-domimplementation-createdocumenttype①

ブラウザーの互換性

関連情報