document.queryCommandSupported

  • Revision slug: Web/API/document.queryCommandSupported
  • Revision title: document.queryCommandSupported
  • Revision id: 411793
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

Summary

Reports whether or not the specified editor query command is supported by the browser.

Syntax

isSupported = document.queryCommandSupported(command);
command
The command for which to determine support.

If the command is not supported, a NotSupportedError exception is thrown.

Otherwise:

  • If the command has no value, or is disabled, an empty string is returned.
  • The "fontSize" command is handled specially; if its value override is set, that gets converted to an integer number of pixels and returned as a legacy font size.
  • If the command's value override is set, that gets returned.
  • Otherwise, the command's value is returned, as would be returned by {{domxref("document.queryCommandValue()")}}.

Example

Example needed

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatUnknown}} {{CompatGeckoDesktop("9.0")}} 4.0 {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatGeckoMobile("9.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

Specification

  • {{spec("http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#querycommandsupported%28%29", "HTML Editing APIs: queryCommandSupported()")}}

Revision Source

<div>{{DomRef}}</div>


<h2 id="Summary" name="Summary">Summary</h2>
<p>Reports whether or not the specified editor query command is supported by the browser.</p>


<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="syntaxbox">
<var>isSupported</var> = document.queryCommandSupported(<em>command</em>);
</pre>

<dl>
  <dt><code>command</code></dt>
  <dd>The command for which to determine support.</dd>
</dl>

<p>If the command is not supported, a <code>NotSupportedError</code> exception is thrown.</p>

<p>Otherwise:</p>
<ul>
  <li>If the command has no value, or is disabled, an empty string is returned.</li>
  <li>The "fontSize" command is handled specially; if its value override is set, that gets converted to an integer number of pixels and returned as a legacy font size.</li>
  <li>If the command's value override is set, that gets returned.</li>
  <li>Otherwise, the command's value is returned, as would be returned by {{domxref("document.queryCommandValue()")}}.</li>
</ul>


<h2 id="Example" name="Example">Example</h2>
<p>Example needed</p>



<h2 id="Specification" name="Specification">Browser compatibility</h2>
<div>{{CompatibilityTable}}</div>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoDesktop("9.0")}}</td>
        <td>4.0</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoMobile("9.0")}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>


<h2 id="Specification" name="Specification">Specification</h2>
<ul>
<li>{{spec("http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#querycommandsupported%28%29", "HTML Editing APIs: queryCommandSupported()")}}</li>
</ul>
Revert to this revision