一般论坛都有这些功能  例如选定一段文本框中的文本然后在下拉列表选择一种颜色,颜色的html标签就被加到文本两边了~    这种功能如何实现?

解决方案 »

  1.   

    楼主可以参考Jscript手册
    有很多方法,具体想加什么标签就用什么方法
    比如
    anchor()
    big()
    blink()
    bold()
    fixed()
    fontcolor()
    等等
      

  2.   

    http://www.codeproject.com/jscript/htmlarea.asp
    下载下来研究一下把
      

  3.   

    <input type="button" value="粗体" onclick="IframeID.document.execCommand('bold',true)">
    <input type="button" value="代码" onclick="alert(IframeID.document.body.innerHTML)"><br />
    <br />
    <iframe id="HtmlEditor" marginheight="0" marginwidth="0" width="200" height="50">
    </iframe>
    <script language="javascript">
    var IframeID=frames["HtmlEditor"];
    //HtmlEditor=document.getElementById("HtmlEditor").contentWindow;
    IframeID.document.designMode="On"
    IframeID.document.open();
    IframeID.document.close();
    IframeID.document.body.contentEditable = "True";
    IframeID.document.body.innerHTML = "<br />我是你们的朋友";
    </script>
      

  4.   

    谢谢你们   。忘情火你给的网站真是好~pehrim你的代码棒极了~~~