Document.queryCommandSupported()
Deprecated
Avoid using this feature in new projects.
The execCommand() method is "not implemented consistently or fully by user agents, and it is not expected that this will change in the foreseeable future."
This feature may be a candidate for removal from web standards or browsers.>
Consider using the following features instead: Async clipboard或contenteditable.>
Document.queryCommandSupported() 方法确定浏览器是否支持指定的编辑指令。
语法
isSupported = document.queryCommandSupported(command);
command-
待确定是否支持的命令。
如果命令不被支持,将触发 NotSupportedError 异常。
另外:
- 如果命令没有值或未启用,将返回空字符串。
- "fontSize" 命令将被特殊处理,如果值被重写,它将返回最近似标准尺寸的整数倍像素大小。
- 如果命令的值已被重写,将由重写返回。
- 否则,此命令返回命令的值,如同
document.queryCommandValue().
示例
js
var flg = document.queryCommandSupported("SelectAll");
if (flg) {
// ...Do something
}
规范
此特性不属于任何规范,也不再有望被标准化。