<div id="butt">
<input type="button" value="提交代码" onclick="show()">
</div><div id="CodeArea">
<br/>
<h2>编辑您的代码:</h2>
<textarea id="TestCode" wrap="logical">
<html><body><img src="\website1\image\eg_landscape.jpg"></img><p>一些老的浏览器不支持 iframe。</p>
<p>如果得不到支持,iframe 是不可见的。</p>
</body>
</html>
</textarea>
</div></form><div id="result">
<h2>查看结果:</h2>
<iframe frameborder="0" name="i" src="temp.htm"></iframe>
</div>
我该怎么编写javascript代码让textarea的内容在temp.htm里面显示
解决方案 »
- extjs4如何实现鼠标划过的时候改变显示图片
- js问题:页面中id重复了,取值时始终只能取得第一个值
- 谁有JavaScript基础教程第六版的电子书!!!
- js脚本在FF浏览器上不起作用了?
- 关于js的正则表达式替换问题
- 窗口显示文字的问题还未解决!
- 请问这句话是什么意思,执行结果是什么? eval("name=document.all.renyuanname"+id+".value");
- 求菜单,类似于ie菜单模式
- 取子串的问题
- 求助各位大神,我想截取这两个页面中的中文内容, 请问怎么用一个正则提取出来?
- Iframe中调有父方法
- 大侠帮帮我 为什么Jquery layout 里操作dialog,页面会闪.
function show(){
frames["i"].document.write( document.getElementById('TestCode').value)
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
</head><body>
<div id="butt">
<input type="button" value="提交代码">
</div><div id="CodeArea">
<br/>
<h2>编辑您的代码:</h2>
<textarea id="TestCode" wrap="logical">
<p>一些老的浏览器不支持 iframe。</p>
<p>如果得不到支持,iframe 是不可见的。</p>
</textarea></div></form><div id="result">
<h2>查看结果:</h2>
<iframe frameborder="0" id="broele" name="i" src="temp.html"></iframe>
</div>
<script type="text/javascript">
jQuery(function($){
$('#butt').find('input').click(function(){
$('#broele').contents().find('body').html($('#TestCode').html());
});});
</script>
</body>
</html>temp.html就是一个空的html模板<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
</body>
</html>
var t=document.getElementById("TestCode").value;
//提取textarea的内容
Var fso=new ActiveXObject(Scripting.FileSystemObject);
Var f=fso.CreateTextFile(“d:\website11\temp.htm”,2,true);
//创建文件temp.htm
f.write(t);
f.close();
//将提取到的textarea的内容写入temp.htm
doucument.getElementById("i")[0].scr="temp.htm";
//将ifame的src属性值改为temp.htm
}