A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/TextRange/queryCommandValue below:

queryCommandValue · WebPlatform Docs

queryCommandValue Summary

Returns the current value of the document, range, or current selection for the given command.

Method of dom/TextRangedom/TextRange

Syntax
var object = document.queryCommandValue();
Parameters cmdID
Data-type
BSTR

String that specifies a command identifier.

Return Value

Returns an object of type DOM NodeDOM Node

Variant

Variant that returns the command value for the document, range, or current selection, if supported. Possible values depend on cmdID. If not supported, this method returns a Variant of type Boolean set to false.

Examples

The following example when using legacy document.selection will display an alert message of ‘false’ if the current selection is not 'bold’, or true if it is already ‘bold’

function makeBold(el){
if(window.getSelection){
    var sel=document.getSelection();
    var range= sel.getRangeAt(0),
    content = range.extractContents(),
    span = document.createElement('b');
    span.appendChild(content);
    var htmlContent = span.innerHTML;
    range.insertNode(span);
}else{
    var sel=document.selection;
    if(sel){
        var rng=sel.createRange();
        alert(rng.queryCommandValue('bold'));

        if(rng.queryCommandSupported('bold')){
            if(rng.queryCommandEnabled('bold')){rng.execCommand('bold',false,null);}
        }
    }
}
}
Usage
 Used for changing the HTML markup of web pages.
Notes Remarks

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.

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4