textarea 不支持html,不能那样

解决方案 »

  1.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无??文档</title>
    <style type="text/css">
    <!--
    .abcc {
    background-color: red;
    }
    --></style>
     <script language="javascript">
    <!--
    function p()
    {
    document.form1.aaaaaa.focus();
     document.getElementById("aaaaaa").outerHTML= "<b>试用</b>" 
    }
    //-->
    </script>
    asdfasdfasdfsadfsadf
    <form name="form1" method="post" action="">
    <textarea name="aaaaaa" id="aaaaaa"></textarea>
    <input name="button" type="button" onclick="p()" value="pasteHTML"/>
    </form>
    </html>
      

  2.   

    参考<script>
    function wfsr(){
    em=document.createElement("b")
    em.innerText = "适用"
    test.appendChild(em)
    }
    function wfsr2(){
    em=document.createElement("A")
    em.innerText="blueidea"
    em.href="http://www.blueidea.com"
    test.appendChild(em)
    }
    </script>
    <button onclick=wfsr()>inertImg</button><button onclick=wfsr2()>inertLink</button>
    <textarea id=test style="width:100%;height:300"></textarea>
      

  3.   

    <script>
    function wfsr(){
    var em=document.createElement("b")
    em.innerText = "适用"
    document.getElementById('test').appendChild(em)
    }
    function wfsr2(){
     var em=document.createElement("A")
    em.innerText="blueidea"
    em.href="http://www.blueidea.com"
    document.getElementById('test').appendChild(em)
    }
    </script>
    <button onclick=wfsr()>inertImg</button><button onclick=wfsr2()>inertLink</button>
    <textarea id=test style="width:100%;height:300"></textarea>
      

  4.   

    <script>
    function wfsr(){
    var em=document.createElement("b");
    var hm = document.getElementById('test').innerHTML;
    em.innerText = document.getElementById('test').innerHTML;
    hm ="";
    document.getElementById('test').appendChild(em)
    }
    </script>
    <button onclick=wfsr()>加粗</button>
    <textarea id=test style="width:100%;height:300"></textarea>
      

  5.   

    这种是可以,但是根本没用.提交的还是文本,而不是超文本.
    多功能编辑器全是用IFRAME将BODY打开成DESIGN模式来实现编辑功能的.
      

  6.   

    想提交超文本textarea,可以考虑使用selection的htmlText属性,先全选得到其htmlText,然后把值给一个hidden
      

  7.   

    ttyp(@http://www.cnblogs.com/ttyp/) 够酷