想要一个可以象csdn一样,写内容有变粗,颜色变化这样功能的控件
就是向回帖或者写贴的时候可以修改文字的东西这个是怎么做的啊?
希望能说说

解决方案 »

  1.   

    FCKEditor,很好,你自己去baidu搜下,
      

  2.   

    网上看到的复制下来保存就能用<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>iframe demo </title>
    </head><body>
    <table style="width: 760px">
    <td>
        <input onClick="format('Bold')"
        type="button" value="粗"/>
        <input onClick="format('UnderLine')"
        type="button" value="划"/>
        <input onClick="format('Italic')"
        type="button" value="斜"/> |
        <input onClick="format('JustifyLeft')"
        type="button" value="左"/>
        <input onClick="format('JustifyCenter')"
        type="button" value="中"/>
        <input onClick="format('JustifyRight')"
        type="button" value="右"/> |
        <input onClick="format('CreateLink', prompt('链接的URL?'))"
        type="button" value="链"/>
        <input onClick="format('Unlink')" type="button" value="销"/>
        <input onClick="format('InsertImage', prompt('图片的URL?'))"
        type="button" value="图"/>|    
        <input onClick="message()" type="button" value="弹"/>
    </td>
    <td align="right">
        <input onClick="insert(prompt('要插入的字符串?'))"
        type="button" value="插入"/>
        <input onClick="format('FontName', prompt('应用哪种字体?', '黑体'))"
        type="button" value="字体"/>
        <select onChange="format('FontSize', this.value)">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
        </select>
        <select onChange="format('ForeColor', this.value)">
          <option value="#000000">黑</option>
          <option value="#ff0000">红</option>
          <option value="#ffff00">黄</option>
          <option value="#00ff00">绿</option>
          <option value="#00ffff">青</option>
          <option value="#0000ff">蓝</option>
          <option value="#ff00ff">紫</option>
        </select>
    </td>
    </table>
    <iframe frameborder="0" id="WebEditor" style="border: 1px dashed black;
    height: 320px; width: 760px"></iframe>
    <script language="javascript">
    Editor = document.getElementById("WebEditor").contentWindow;
    Editor.document.designMode = "on";
    //Editor.document.contentEditable = true;
    Editor.document.open();
    //Editor.document.write("");
    Editor.document.close();Editor.document.onkeypress = fnKeypress;
    function fnKeypress(){
    if(document.all){
    var ev = Editor.event;
    if(ev.keyCode==13 && !ev.shiftKey){
    var s = Editor.document.selection;
    if (s!=null){
    var r = s.createRange();
    if (r!=null) {r.pasteHTML("<BR/>");r.select();}
    }
    return false;
    }
    }
    }function format(what, opt)
    {
        Editor.focus();
        Editor.document.execCommand(what, false, opt);
    }function insert(html)
    {
    debugger;
        if(window.event)
        Editor.document.selection.createRange().pasteHTML(html);
        else
        format("insertHTML", html);
    }function message()
    {
    if(document.all)
    alert(Editor.document.selection.createRange().text);
        else{
        //alert(Editor.document.getSelection());
    alert(Editor.getSelection());
    var selection = Editor.getSelection().getRangeAt(0);
    var linkElement = Editor.document.createElement("a"); //创建一个新的<A>节点
    linkElement.href = "http://asers.blog.sohu.com";//设置<A>节点的href属性
    selection.surroundContents(linkElement);//加入超链接
    }
    }
    </script>
    </body>
    </html>