到这里看吧,呵呵。
http://www.microsoft.com/china/msdn/workshop/createwp.asp

解决方案 »

  1.   

    例子参见:
    http://www.csdn.net/develop/Read_Article.asp?Id=8243execCommand Method
    Executes a command on the current document, current selection, or the given range.SyntaxbSuccess = object.execCommand(sCommand [, bUserInterface] [, vValue])
    ParameterssCommand
    Required. String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. 
    bUser
    Interface Optional. Boolean that specifies one of the following values: 
    false Default. Does not display a user interface. 
    true Displays a user interface, if the command supports one. 
     
    vValue 
    Optional. Variant that specifies the string, number, or other value to assign. Possible values depend on sCommand . Return ValueBoolean that returns one of the following values:true The command was successful. 
    false The command was not successful. ResDo not invoke the execCommand method until after the page loads.The bUserInterface and vValue parameters may be required depending on the command being executed.Standards InformationThere is no public standard that applies to this method. Applies To document, controlRange, TextRange 
      

  2.   

    execCommand(strCommand,arg1,arg2)首先,它适用于 TextRange 对象或者 是可编辑的页面的 Document 对象TextRange对象 可以用 var oTextRange document.createTextRange() 方法获得一个
    也可以是从 document.selection 创建
     var oTextRange=document.selection.createRange()  //注意这里用createRange不是createTextRange如果整个页面可以编辑  editmode=1 (IE 5以上任何版本) 或者是 页面上某个标记设置成 contentEditable="true" (一般是DIV,此方法需要 IE 5.5或者以上的版本支持)常用的命令集可以到 http://msdn.microsoft.com/workshop/author/dhtml/reference/commandids.asp
    查到。。比如说让一个被选择的文字高亮显示:
    onmouseup事件:
    <script>
    function maskText(){
     if(document.selection.type=="Text"){
     oTextRange=document.selection.createRange(); 
     oTextRange.execCommand("OverWrite","true");          //设置覆盖模式
     oTextRange.execCommand("BackColor",true,"#CC0066");  //改变背景颜色       
     oTextRange.execCommand("ForeColor",true,"#FFFF00");  //改变前景颜色
     oTextRange.execCommand("UnSelect");                  //取消选择
     }
    }
    document.onmouseup=maskText;
    </script>
      

  3.   

    不好意思,有点小错误:
    如果整个页面可以编辑  designmode=1 (IE 5以上任何版本)
      

  4.   

    哇....我辛辛苦苦写了这么多...
    那都是偶亲自下橱啊...而不是ctrl+C   ctrl+V