Document.queryCommandSupported()

The Document.queryCommandSupported() method reports whether or not the specified editor command is supported by the browser.

Syntax

JavaScript
<var>isSupported</var> = document.queryCommandSupported(<var>command</var>);

Parameters

command
The command for which to determine support.

Return value

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

Notes

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 [1]

Example

JavaScript
var flg = document.queryCommandSupported("SelectAll");

if(flg) {
  // ...Do something
}

Specifications

Specification Status Comment
HTML Editing APIs
The definition of 'querycommandsupported' in that specification.
Editor's Draft Initial definition

Browser compatibility

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

[1] Before Firefox 41, for the command 'paste' Firefox incorrectly returned true when the paste feature was available but the calling script had insufficient privileges to actually perform the action.

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/document/querycommandsupported

API DOM editor Method Reference