queryCommandEnabled
Summary
Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document.
Method of dom/TextRangedom/TextRange
Syntax
var Result = document.queryCommandEnabled(/* see parameter list */);
Parameters
cmdID
- Data-type
- BSTR
String that specifies a command identifier.
see dottoro.com for a full listing of commands.
Return Value
Returns an object of type BooleanBoolean
Boolean
Boolean that returns one of the following possible values:
Return value | Description |
---|---|
true | The command is enabled. |
false | The command is disabled. |
Examples
The following example is a onClick handler to execute the 'cut' command.
function execCut(){ if(document.queryCommandEnabled('cut')){ document.execCommand('cut',false,null);} }
Notes
Remarks
Using queryCommandEnabled ("delete") on a TextRange object returns true, while queryCommandEnabled ("delete") on a Document object returns false. However, execCommand ("delete") can still be used to delete the selected text. This method is a wrapper function for the command constants. You can obtain an IHTMLDocument2 interface using IID_IHTMLDocument2 for the IID. This method is a wrapper function for the command constants. You can obtain an IHTMLControlRange interface using IID_IHTMLControlRange for the IID. This method is a wrapper function for the command constants. You can obtain an IHTMLTxtRange interface using IID_IHTMLTxtRange for the IID.
See also
Other articles
help.dottoro.com - Command Reference
Attributions
Microsoft Developer Network: [queryCommandEnabled Method Article]