MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

Document.queryCommandEnabled()

这篇翻译不完整。请帮忙从英语翻译这篇文章

 Document.queryCommandEnabled() 方法用来查询浏览器是否支持指定的富文本编辑指令。

语法

isEnabled = document.queryCommandEnabled(command);

参数

command
要查询的是否支持的指令.

Return value

Returns a Boolean which is true if the command is enabled and false if the command isn't.

Notes

  • For 'cut' and 'copy' commands the method only returns true when called from a user-initiated thread.
  • The 'paste' command return false not only if the feature is unavailable, but also if the script calling it has insufficient privileges to perform the action.

Example

var flg = document.queryCommandEnabled("SelectAll");

if(flg) {
  document.execCommand("SelectAll", false, null); // command is enabled, run it
}

Specifications

Specification Status Comment
HTML Editing APIs
querycommandenabled
Editor's Draft Initial definition

Browser compatibility

  
Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 17 (Yes) 9.0 (9.0)[1] 4.0 ? ?
  
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) 9.0 (9.0)[1] ? ? ?

[1] Before Firefox 41, queryCommandEnabled() with arguments cut, copy or paste would throw errors unless the script had special privileges.

See also

 

<embed height="0" id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd" type="application/thunder_download_plugin" width="0">

文档标签和贡献者

 此页面的贡献者: ucev
 最后编辑者: ucev,