DOMImplementation.createDocumentType()

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

DOMImplementation.createDocumentType() 方法返回一个 DocumentType 对象,它可以在文档创建时用在 DOMImplementation.createDocument ,或者通过Node.insertBefore()Node.replaceChild() 等方法放在文档中。

语法

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

参数

qualifiedNameStr
 DOMString 类型的值,包含一个合规的名称,如 svg:svg
publicId
 DOMString 类型的值, 包含 PUBLIC 标识符。
systemId
 DOMString 类型的值,包含 SYSTEM 标识符。

示例

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
DOMImplementation.createDocumentType
Living Standard Document Object Model (DOM) Level 3 Core Specification相比无改动
Document Object Model (DOM) Level 3 Core Specification
DOMImplementation.createDocumentType
Obsolete Document Object Model (DOM) Level 2 Core Specification 相比无改动
Document Object Model (DOM) Level 2 Core Specification
DOMImplementation.createDocumentType
Obsolete 初次定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
createDocumentTypeChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 9Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

参见