execCommand("Underline")
就可以了

解决方案 »

  1.   

    给你个例子,依样画葫芦就可以了:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Editable Regions Sample</TITLE>
    <STYLE>
    BODY{margin:0;        background:white;
            font-family:verdana;
            font-size:80%;}
    BUTTON {cursor:hand;
            background:#ffffff; 
            border-color:#99ccff; 
            font-weight:bold;}
    .bar{background:#336699;
            width:100%;
            height:30px;
            border-top:1px solid #99CCFF;
            border-bottom:1px solid #000000;}
    .desbar{background:#FFFFFF;
            width:100%;
            padding: 10px;
            border-top:1px solid #CCCCCC;
            border-bottom:1px solid #000000;
            color:black; 
            font-size:8pt;
            height:105;}
    .title{font-size:15pt;
            color:white;
            padding-left:10px;}
    .bar A:link {text-decoration:none; color:white}
    .bar A:visited {text-decoration:none; color:white}
    .bar A:active {text-decoration:none; color:white}
    .bar A:hover {text-decoration:none; color:yellow}
    </STYLE><SCRIPT>function fnInit(){
        for (i=0; i<document.all.length; i++)
            document.all(i).unselectable = "on";
        oDiv.unselectable = "off";
    }function fnToggleEdits(oObj,oBtn) {
        currentState = oObj.isContentEditable;
        newState = !currentState;
        oObj.contentEditable = newState;    newState==false ? oBtn.innerHTML='Turn Editing On' :
            oBtn.innerHTML='Turn Editing Off';
    }</SCRIPT>
    </HEAD><BODY onload="fnInit();"><DIV CLASS="desbar">
        <H4 style="font-size:10pt;">This example demonstrates the features of 
            Microsoft&#174; Internet Explorer that enable users to edit the content
            of an HTML element directly from the browser.</H4>
        <P>This HTML editor is a <B>DIV</B> element set to be content-editable. Any 
            valid HTML content (text, images, form controls, etc.) can be pasted 
            and edited in this editor.</P>    <DIV ALIGN="center">
            <DIV ALIGN="center" STYLE="height:210; width:90%; 
                background-color:#99CCFF; border:1px solid black">  
                <DIV CLASS="bar title">HTMLEditor (Content-Editable DIV)</DIV>            <DIV style="padding:10px">
                    <BUTTON ID="oEditDiv" TITLE="Turn Editing Off"
                      onclick='fnToggleEdits(oDiv,oEditDiv);oDiv.focus();'>
                      Turn Editing Off</BUTTON>  
                    <BUTTON ID="oBoldBtn" TITLE="Bold" 
                      onclick='if (oDiv.isContentEditable==true) 
                      document.execCommand("Bold");'><B>Bold</B></BUTTON>  
                    <BUTTON ID="oItalicBtn" TITLE="Italic" 
                      onclick='if (oDiv.isContentEditable==true) 
                      document.execCommand("Italic");'><I>Italic</I></BUTTON>  
                    <BUTTON ID="oUndLnBtn" TITLE="Underline" 
                      onclick='if (oDiv.isContentEditable==true) 
                      document.execCommand("Underline");'><U>Underline</U></BUTTON>
                </DIV>
                <DIV id=oDiv CONTENTEDITABLE ALIGN=left STYLE="height:100; 
                    width:95%;background-color:white; font-face:Arial; padding:3;    
                    border:inset #99ccff; scrollbar-base-color:#99ccff; 
                    overflow=auto;"></DIV> 
                      </DIV>
        </DIV>
    </body>
    </html>
      

  2.   

    非常感谢你回复的代码,我放在网页里使用了下发现它不能操做文档,另外我最想知道的是如何才能把它作为一个独立的插件放在流览器中对所有网页都有效呢(就像http://www.iup.com/download/一样)?
      

  3.   

    是在应用程序中对webbrowser控件内文档的进行修饰的控件(如斜体,粗体,加入小的记事本,下划标记符等)然后将软件打包给用户安装,我不知如何在webbrowser外部对其中的文档属性操作。
      

  4.   

    那你就必须用delphi或vc来写了,
    据我所知,javascript目前还没有这些功能