--- title: DOMImplementation slug: Web/API/DOMImplementation tags: - API - DOM - Interface - Reference translation_of: Web/API/DOMImplementation ---

{{ ApiRef("DOM") }}

DOMImplementation 接口代表了一个对象,这个对象提供了不依赖于任何document的方法。这个对象可以通过{{domxref("Document.implementation")}}属性获得

属性

这个接口没有特定的属性,并且也没有继承到任何属性。

方法

没有继承的方法

{{domxref("DOMImplementation.createDocument()")}}
创建并返回一个 {{domxref("XMLDocument")}}对象.
{{domxref("DOMImplementation.createDocumentType()")}}
创建并返回一个 {{domxref("DocumentType")}}对象.
{{domxref("DOMImplementation.createHTMLDocument()")}}
创建并返回一个 {{domxref("Document")}}对象.
{{domxref("DOMImplementation.hasFeature()")}}
返回一个是否支持所给定特性的{{domxref("Boolean")}}值。这个方法是不可靠的,仅用于兼容性目的:除了SVG相关的查询,它总是返回 true。旧浏览器的行为非常不一致
Returns a {{domxref("Boolean")}} indicating if a given feature is supported or not. This function is unreliable and kept for compatibility purpose alone: except for SVG-related queries, it always returns true. Old browsers are very inconsistent in their behavior.

规范

Specification Status Comment
{{SpecName('DOM WHATWG', '#domimplementation', 'DOMImplementation')}} {{Spec2('DOM WHATWG')}} Removed the getFeature() method.
Added the createHTMLDocument() method.
Modified the return type of createDocument() from {{domxref("Document")}} to {{domxref("XMLDocument")}}.
{{SpecName('DOM3 Core', 'core.html#ID-102161490', 'DOMImplementation')}} {{Spec2('DOM3 Core')}} Added the getFeature() method (never implemented by any user agent).
{{SpecName('DOM2 Core', 'core.html#ID-102161490', 'DOMImplementation')}} {{Spec2('DOM2 Core')}} Added the createDocument() and createDocumentType() methods.
{{SpecName('DOM1', 'level-one-core.html#ID-102161490', 'DOMImplementation')}} {{Spec2('DOM1')}} Initial definition.

浏览器兼容性

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{CompatGeckoDesktop("1.0")}} 6.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
createHTMLDocument() {{CompatVersionUnknown}} {{CompatGeckoDesktop("2.0")}} 9.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
createDocument() {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.0")}} 9.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
hasFeature() {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.0")}} [1] 6.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
createDocumentType() {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.0")}} 9.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
createHTMLDocument() {{CompatVersionUnknown}} {{CompatGeckoMobile("2.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
createDocument() {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
hasFeature() {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
createDocumentType() {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

[1] Since Gecko 19, hasFeature() mostly returns true.

See also