blob: 85b083217ed200a9395de7ba6e4e1230cdd5501b (
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
|
---
title: Node.isSupported
slug: Web/API/Node/isSupported
translation_of: Web/API/Node/isSupported
---
<p>{{obsolete_header(22)}} {{ ApiRef() }}</p>
<h2 id="Summary" name="Summary">概述</h2>
<p>检测当前环境是否在某个节点上实现了指定的DOM特性.</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox">node.isSupported(feature, version)</pre>
<dl>
<dt>
<code>feature</code></dt>
<dd>
需要检测的特性名称.这个参数和<a href="/zh-CN/docs/DOM/document.implementation" title="/zh-CN/docs/DOM/document.implementation">DOMImplementation</a>对象上的<code>hasFeature</code>方法的同名参数作用相同,其中所有有效的特性名称都列在了DOM Level 2中的<a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/introduction.html#ID-Conformance">Conformance一节</a>.</dd>
<dt>
<code>version</code></dt>
<dd>
<p>需要检测的特性版本号.在DOM Level 2第一版中,这个参数的值应该写为字符串<code>2.0</code>.如果省略了这个参数,则无论环境实现了哪个版本的需检测特性,这个方法都会返回<code>true</code>.</p>
</dd>
</dl>
<h2 id="Example" name="Example">示例</h2>
<pre class="brush: html"><div id="doc">
</div>
<script>
// 获取一个元素,然后检查它是否支持DOM2 HTML模型.
var main = document.getElementById('doc');
var output = main.isSupported('HTML', '2.0');
</script>
</pre>
<h2 id="规范">规范</h2>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-Node-supports">DOM Level 2 Core: isSupported</a></p>
<h2 id="Gecko附注">Gecko附注</h2>
<ul>
<li>从Gecko 19.0 {{geckoRelease("19.0")}}开始,该方法的结果总是会返回<code>true </code>({{bug("801425")}}),从Gecko 22.0 {{geckoRelease("22.0")}}起,该方法被彻底删除.</li>
</ul>
|