web api instance method
DocumentType: replaceWith() method
The DocumentType.replaceWith() method replaces the document type with a set of given nodes.
Syntax
replaceWith(node1)
replaceWith(node1, node2)
replaceWith(node1, node2, /* …, */ nodeN)
Parameters
node1, …,nodeN- : A set of nodes to replace the
DocumentTypewith.
- : A set of nodes to replace the
Return value
None (undefined).
Exceptions
HierarchyRequestErrorDOMException- : Thrown when the node cannot be inserted at the specified point in the hierarchy.
Examples
Using replaceWith()
let svgDt = document.implementation.createDocumentType(
"svg:svg",
"-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);
document.doctype.replaceWith(svgDt);
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.