--- title: Document.queryCommandSupported() slug: Web/API/Document/queryCommandSupported tags: - API - Commandes - DOM - Document - Méthodes - editeur translation_of: Web/API/Document/queryCommandSupported ---
La méthode Document.queryCommandSupported() indique si la commande d'éditeur spécifiée est prise en charge par le navigateur.
isSupported = document.queryCommandSupported(command);
commandRenvoie un {{jsxref("Boolean")}} qui est true (vrai) si la commande est prise en charge et false (faux) sinon.
La commande 'paste' (coller) renvoie false (faux), pas seulement si la fonctionnalité n'est pas disponible, mais également si le script l'appelant a des privilèges insuffisants pour réaliser l'action [1].
var flg = document.queryCommandSupported("SelectAll");
if(flg) {
// ...Faire quelque chose
}
| Spécification | Statut | Commentaire |
|---|---|---|
| {{SpecName('HTML Editing','#querycommandsupported()','querycommandsupported')}} | {{Spec2('HTML Editing')}} | Définition initiale. |
| Fonctionnalité | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 17 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("9.0")}}[1] | 4.0 | {{CompatUnknown}} | 6.1.6 |
| Fonctionnalité | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("9.0")}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] Avant Firefox 41, pour la commande 'paste' (coller), Firefox renvoyait incorrectement true (vrai) quand la fonctionnalité coller était disponible même si le script appelant avait des privilèges insuffisants pour réaliser l'action.