aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/querycommandsupported/index.html
blob: de033d485ce72889881ee53028fd9887e7dff0fc (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
title: Document.queryCommandSupported()
slug: Web/API/Document/queryCommandSupported
tags:
  - 包括示例
  - 编辑器
translation_of: Web/API/Document/queryCommandSupported
---
<div>{{ ApiRef("DOM") }}</div>

<div> </div>

<p><code><strong>Document.queryCommandSupported()</strong></code> 方法确定浏览器是否支持指定的编辑指令。</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="syntaxbox"><var>isSupported</var> = document.queryCommandSupported(<em>command</em>);
</pre>

<dl>
 <dt><code>command</code></dt>
 <dd>待确定是否支持的命令。</dd>
</dl>

<p>如果命令不被支持,将触发 <code>NotSupportedError</code> 异常。</p>

<p>另外:</p>

<ul>
 <li>如果命令没有值或未启用,将返回空字符串。</li>
 <li>"fontSize" 命令将被特殊处理,如果值被重写,它将返回最近似标准尺寸的整数倍像素大小。</li>
 <li>如果命令的值已被重写,将由重写返回。</li>
 <li>否则,此命令返回命令的值,如同 {{domxref("document.queryCommandValue()")}}.</li>
</ul>

<h2 id="Example" name="Example">示例</h2>

<pre class="brush:js">var flg = document.queryCommandSupported("SelectAll");

if(flg) {
  // ...Do something
}
</pre>

<h2 id="Specification" name="Specification">浏览器兼容性</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>特性</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("9.0")}}</td>
   <td>4.0</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th><span style="font-family: open sans light,helvetica,arial,sans-serif; font-size: 16px; line-height: 16px;">特性</span></th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("9.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="Specification" name="Specification">规范</h2>

<table class="spectable standard-table">
 <tbody>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML Editing','#querycommandsupported()','querycommandsupported')}}</td>
   <td>{{Spec2('HTML Editing')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="See_also" name="See_also">参见</h2>

<ul>
 <li>{{domxref("document.execCommand")}}</li>
</ul>