JavaScript Reference/Javascript Methods/queryCommandState — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:22, 26 мая 2010

"queryCommandState()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
    var myText = document.selection.createRange();
    if (!myText==""){
        if (myText.queryCommandEnabled("Delete") == true) {
          document.execCommand("Delete");
        }
    }
    var m = myText.queryCommandState("Delete");
    if (m == false) {
       alert("Delete command has not been executed");
    } 
} 
</script>
<p id="myText">
Select text in this paragraph, and then click button.</p>
<input type="button" value="Click to delete selection and verify command state" onclick="function1();">
</body>
</html>



"queryCommandState()" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |controlRange*                   document                      |
|                |TextRange                                                     |
+----------------+--------------------------------------------------------------+



"queryCommandState()" Syntax, Parameters and Note

Note:
Has the command already been executed. 
Returns true or false.
    
Syntax:
    
controlRangeName.queryCommandState(param1)
objectName.queryCommandState(param1)
Parameters:
    param1   Required; the name of the command. 
                       For a complete list of commands, go to 
                       http://msdn.microsoft.ru/workshop/author/dhtml/reference/commandids.asp.