Document.queryCommandSupported() メソッドは指定したエディタコマンドがブラウザでサポートされているかどうかを報告します。
構文
isSupported = document.queryCommandSupported(command);
-
引数
command- サポートしているかを調べるコマンド。
戻り値
Boolean 値。コマンドがサポートされていれば true、そうでなければ false を返します。
注記
'paste' コマンドは機能が利用できないときだけでなく、呼び出しスクリプトにそのコマンドを実行するための権限が不足しているときにも false を返します。 [1]
例
var flg = document.queryCommandSupported("SelectAll");
if(flg) {
// ...何か行う
}
仕様書
| 仕様 | 状態 | コメント |
|---|---|---|
| HTML Editing APIs The definition of 'querycommandsupported' in that specification. |
勧告改訂案 | 最初の定義 |
ブラウザの互換性
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基本サポート | 17 | 9.0 (9.0)[1] | 4.0 | ? | ? |
| 機能 | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| 基本サポート | ? | 9.0 (9.0)[1] | ? | ? | ? |
[1] Firefox 41 より前のバージョンでは、 Firefox は'paste' コマンドに対してペースト機能が利用可能であっても実際にコマンドを実行する権限が不足していたときに誤って true を返します。