MSHTML Methods: queryCommandSupported

Scripting Syntax

bSupported = object.queryCommandSupported (sCommand);

Object

The queryCommandSupported method applies to the document and TextRange objects and the controlRange collection.

Arguments

The required sCommand argument names a command to execute. There are many supported commands.

Return Value

The method returns true if the named command is supported for scripting. Otherwise, it returns false.

Behaviour

The queryCommandSupported method tests whether scriptable access to the object’s IOleCommandTarget interface is supported for the given command.

The case-insensitive command name given as sCommand translates to a numeric command ID in the MSHTML command group represented programmatically by CGID_MSHTML. Even within this command group, only a small subset of the commands that are supported through the IOleCommandTarget interface are supported for scripting.

The queryCommandSupport method is simply a test of whether the given command is in that subset.

There is a demonstration here. To see it, please enable scripting and then refresh this page.

function Test_document_queryCommandSupported ()
{
    var cmd = prompt ("Enter the name of an MSHTML command to query for being supported:", "");
    if (cmd == null) return;

    var result = document.queryCommandSupported (cmd);
    alert ('queryCommandSupported ("' + cmd + '") for the document returned ' + result);
}