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 July 2015.

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①

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
createDocumentType

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報