Returns the current value of the document, range, or current selection for the given command.
Method of dom/TextRangedom/TextRange
Syntaxvar object = document.queryCommandValue();
Parameters cmdID
String that specifies a command identifier.
Return ValueReturns 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.
ExamplesThe 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.
AttributionsMicrosoft Developer Network: [queryCommandValue Method Article]
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