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
createDocumentType(name, publicId, systemId)
Parameter
name
-
Ein String, der den Namen des Doctypes, wie
html
, enthält. Entspricht derDocumentType.name
-Eigenschaft. publicId
-
Ein String, der die
PUBLIC
-Kennung enthält. Entspricht derDocumentType.publicId
-Eigenschaft. systemId
-
Ein String, der die
SYSTEM
-Kennungen enthält. Entspricht derDocumentType.systemId
-Eigenschaft.
Rückgabewert
Ein DocumentType
.
Beispiele
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
- Die
DOMImplementation
-Schnittstelle, zu der es gehört.