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() 等方法放在文档中。
语法
var doctype = document.implementation.createDocumentType(qualifiedNameStr, publicId, systemId);
参数
示例
js
var dt = document.implementation.createDocumentType(
"svg:svg",
"-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);
var 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①> |
浏览器兼容性
Loading…
参见
- 该方法所属的接口
DOMImplementation