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


这是一个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>


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3