DOMImplementation.createDocumentType() 方法返回 DocumentType object which can either be used with DOMImplementation.createDocument upon document creation or can be put into the document via methods like Node.insertBefore() or Node.replaceChild() .

句法

var doctype = document.implementation.createDocumentType(qualifiedNameStr, publicId, systemId);
					

参数

qualifiedNameStr
DOMString containing the qualified name, like svg:svg .
publicId
DOMString containing the PUBLIC 标识符。
systemId
DOMString containing the SYSTEM identifiers.

范例

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
						

规范

规范 状态 注释
DOM
The definition of 'DOMImplementation.createDocumentType' in that specification.
实时标准 无变化自 DOM (文档对象模型) 3 级核心规范
DOM (文档对象模型) 3 级核心规范
The definition of 'DOMImplementation.createDocumentType' in that specification.
过时 无变化自 DOM (文档对象模型) 级别 2 核心规范
DOM (文档对象模型) 级别 2 核心规范
The definition of 'DOMImplementation.createDocumentType' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
createDocumentType Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: