页面导航: 首页网络编程JavaScript应用技巧 → 正文内容

在textarea文本域中显示HTML代码的方法

发布:dxy 字体:[增加 减小] 类型:转载
这是一个iframe 的
给你一个参考的:   
  <iframe   ID="tryit"   MARGINHEIGHT="1"   MARGINWIDTH="1"   width="100%"   height="300"   scrolling="auto"></iframe>   
  <script   language=javascript>   
        tryit.document.designMode="On";   
        tryit.document.open();   
        tryit.document.innerHTML+=tryit.document.write("<b>asdf</b>");   
        tryit.document.close();   
        tryit.focus();   
  </script>  
这个是textarea   
<body>   
  <textarea   id="txt"   rows=10   cols=10></textarea>   
  <button   onclick="insert()">click</button>   
  <script>   
  function   insert(){   
  var   oDiv=document.createElement("DIV");   
  oDiv.innerHTML="<br><Font   color   =   Red>red<BR></FONT><Font   color   =   Blue>blue</font>";   
  document.getElementById("txt").appendChild(oDiv);   
    
  }   
  </script> 
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行