aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/implementation/index.html
blob: 473cf729a79670353c6ebd6ec41c4d2c5cc42569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: document.implementation
slug: Web/API/Document/implementation
translation_of: Web/API/Document/implementation
---
<div>
 {{ApiRef}}</div>
<h2 id="概要">概要</h2>
<p>返回一个和当前文档相关联的{{domxref("DOMImplementation")}}对象。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"><var>DOMImpObj</var> = document.implementation;
</pre>
<h2 id="示例">示例</h2>
<pre class="brush: js">var modName = "HTML";
var modVer = "2.0";
var conformTest = document.implementation.hasFeature( modName, modVer );

alert( "DOM " + modName + " " + modVer + " supported?: " + conformTest );

// alerts with: "DOM HTML 2.0 supported?: true" if DOM Level 2 HTML module is supported.
</pre>
<p>可以在<a href="http://www.w3.org/TR/DOM-Level-2-Core/introduction.html#ID-Conformance-h2" style="line-height: 1.5;">一致性章节</a>中查看可用的一系列DOM2级模型名称<span style="line-height: 1.5;">(例如:Core, HTML, XML等等)。</span></p>
<h2 id="说明">说明</h2>
<p>W3C的DOM1级建议值规定了一种检测浏览器对某个DOM模型是否支持的方法——<code>hasFeature方法</code>(请参考上边的例子以及这篇文章 <a href="http://www.w3.org/2003/02/06-dom-support.html">What does your user agent claim to support?</a>)。如果它可用的话,那么<code>DOMImplementation接口的其他方法就可以为操作文档以外的内容提供一些服务了。例如,</code><code>DOMImplementation接口包含一个</code><code>createDocumentType方法,它可以为实例管理的文档创建对应的DTD文档定义。</code></p>
<h2 id="方法">方法</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th>名称</th>
   <th>动作</th>
   <th>返回值</th>
  </tr>
  <tr>
   <td>{{domxref("DOMImplementation.createDocument","createDocument")}} (<code>namespaceURI</code>, <code>qualifiedNameStr</code>, {{domxref("DocumentType")}} )</td>
   <td> </td>
   <td>{{domxref("document")}}</td>
  </tr>
  <tr>
   <td>{{domxref("DOMImplementation.createDocumentType","createDocumentType")}} ( <code>qualifiedNameStr</code>, <code>publicId</code>, <code>systemId</code> )</td>
   <td> </td>
   <td>{{domxref("DocumentType")}}</td>
  </tr>
  <tr>
   <td>{{domxref("DOMImplementation.createHTMLDocument","createHTMLDocument")}} ( <code>title</code> )</td>
   <td> </td>
   <td>{{domxref("document")}}</td>
  </tr>
  <tr>
   <td>{{domxref("DOMImplementation.getFeature","getFeature")}} ( <code>feature</code>, <code>version</code> )</td>
   <td> </td>
   <td>{{domxref("DOMObject")}}</td>
  </tr>
  <tr>
   <td>{{domxref("DOMImplementation.hasFeature","hasFeature")}} ( <code>feature</code>, <code>version</code> )</td>
   <td> </td>
   <td>{{domxref("Boolean")}}</td>
  </tr>
 </tbody>
</table>
<h2 id="规范">规范</h2>
<ul>
 <li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490">DOM2级核心: implementation</a></li>
 <li><a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490">DOM3级核心: implementation</a></li>
</ul>
<h2 id="Gecko引擎的特别说明">Gecko引擎的特别说明</h2>
<ul>
 <li>从Gecko 19.0 {{geckoRelease("19.0")}}开始{{domxref("DOMImplementation.hasFeature","hasFeature")}}方法总是返回true。</li>
</ul>