You are here: Reference > JavaScript > client-side > selection and ranges > methods > queryCommandValue (document, TextRange, ...)

queryCommandValue method (document, TextRange, ...)

Browser support:
Returns the actual value of the specified command.
If no value belongs to the specified command, the queryCommandValue method returns false.

Syntax:

object.queryCommandValue (commandIdentifier);
You can find the related objects in the Supported by objects section below.

Parameters:

commandIdentifier
Required. A case-insensitive string that specifies the name of the command. See command identifiers for more information.

Return value:

If no value belongs to the specified command, it returns false, else the returned value and its type depend on the specified command.

Example HTML code 1:

This example illustrates the use of the queryCommandValue method:
<head>
    <script type="text/javascript">
        function GetFont () {
            alert (document.queryCommandValue ('fontname'));
        }
    </script>
</head>
<body>
    <div contenteditable="true">
        <span style="font-family:arial;">Some text in Arial font.</span>
        <br />
        <span style="font-family:verdana;">Some text in Verdana font.</span>
    </div>
    <br /><br />
    <button onclick="GetFont ();">Get the font name of the selected text!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content