当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 在textarea文本域中显示HTML代码的方法

Javascript
纯JS半透明Tip效果代码
JavaScript 读URL参数增强改进版版
JS对URL字符串进行编码/解码分析
javescript完整操作Table的增加行,删除行的列子大全
js可填可选的下拉框
prototype Element学习笔记(篇一)
prototype Element学习笔记(篇二)
prototype Element学习笔记(Element篇三)
Prototype使用指南之selector.js说明
不唐突的JavaScript的七条准则整理收集
js判断变量是否空值的代码
Firefox getBoxObjectFor getBoundingClientRect联系
Div自动滚动到末尾的代码
javascript笔试题目附答案
javascript引导程序
js身份证验证超强脚本
JS给元素注册事件的代码
JavaScript函数、方法、对象代码
JS写的数字拼图小游戏代码[学习参考]
关于B/S判断浏览器断开的问题讨论

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 377 ::
收藏到网摘: n/a

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