You are here: Reference > JavaScript > client-side > selection and ranges > methods > queryCommandText (document, TextRange, ...)
queryCommandText method (document, TextRange, ...)
Returns the description of the specified command.
The description of some commands depend on the current state of their target.
To get the state of a command, use the queryCommandState method.
See the example for details.
Note: the queryCommandSupported method is supported by Firefox, but it is not implemented and raises an exception.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. A case-insensitive string that specifies the name of the command. See command identifiers for more information. |
Return value:
String. Information about the specified command.
Example HTML code 1:
This example illustrates the use of the queryCommandText method:
|
||||
<head> <script type="text/javascript"> function GetCommandDescription () { // try..catch is necessary because the queryCommandText method is supported but not implemented in Firefox. try { alert (document.queryCommandText ('Undo')); alert (document.queryCommandText ('Redo')); } catch (e) { alert ("Your browser does not support the queryCommandText method!"); } } </script> </head> <body> <div contenteditable="true">Edit this text to modify the description of the 'undo' and 'redo' commands!</div> <br /><br /> <button onclick="GetCommandDescription ();">Get the description of the 'undo' and 'redo' commands!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
execCommand
queryCommandEnabled
queryCommandIndeterm
queryCommandState
queryCommandSupported
queryCommandValue
queryCommandEnabled
queryCommandIndeterm
queryCommandState
queryCommandSupported
queryCommandValue
External links:
User Contributed Comments