--- title: Document.queryCommandSupported() slug: Web/API/Document/queryCommandSupported tags: - 包括示例 - 编辑器 translation_of: Web/API/Document/queryCommandSupported ---
Document.queryCommandSupported() 方法确定浏览器是否支持指定的编辑指令。
isSupported = document.queryCommandSupported(command);
command如果命令不被支持,将触发 NotSupportedError 异常。
另外:
var flg = document.queryCommandSupported("SelectAll");
if(flg) {
// ...Do something
}
| 特性 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | {{CompatUnknown}} | {{CompatGeckoDesktop("9.0")}} | 4.0 | {{CompatUnknown}} | {{CompatUnknown}} |
| 特性 | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | {{CompatUnknown}} | {{CompatGeckoMobile("9.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
| 规范 | 状态 | 备注 |
|---|---|---|
| {{SpecName('HTML Editing','#querycommandsupported()','querycommandsupported')}} | {{Spec2('HTML Editing')}} |