DOMImplementation: createDocumentType() Methode

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.

Die DOMImplementation.createDocumentType()-Methode gibt ein DocumentType-Objekt zurück, das entweder bei der Dokumenterstellung mit DOMImplementation.createDocument verwendet oder über Methoden wie Node.insertBefore() oder Node.replaceChild() in das Dokument eingefügt werden kann.

Syntax

js
createDocumentType(name, publicId, systemId)

Parameter

name

Ein String, der den Namen des Doctypes, wie html, enthält. Entspricht der DocumentType.name-Eigenschaft.

publicId

Ein String, der die PUBLIC-Kennung enthält. Entspricht der DocumentType.publicId-Eigenschaft.

systemId

Ein String, der die SYSTEM-Kennungen enthält. Entspricht der DocumentType.systemId-Eigenschaft.

Rückgabewert

Beispiele

js
const dt = document.implementation.createDocumentType(
  "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,
);
console.log(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN

Spezifikationen

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

Browser-Kompatibilität

Siehe auch