Document.queryCommandEnabled()

Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

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

Syntax

isEnabled = document.queryCommandEnabled(command);

Parameters

command
The command for which to determine support.

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
execCommand

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
queryCommandEnabled
DeprecatedNon-standard
Chrome Full support 1Edge Full support 12Firefox Full support 41
Full support 41
No support 9 — 41
Notes
Notes queryCommandEnabled with arguments cut, copy or paste would throw errors unless the script had special privileges.
IE Full support 4Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 41
Full support 41
No support 9 — 41
Notes
Notes queryCommandEnabled with arguments cut, copy or paste would throw errors unless the script had special privileges.
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support
Full support
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.

See also