运行代码框
经验与学习 2008/5/6 17:31:36 点击:不统计
关键词:运行代码框,运行代码,运行代码框代码,运行代码框插入网页,运行代码框函数,代码框运行代码
<script>
function runCode() //定义一个运行代码的函数,
{
var code=event.srcElement.parentElement.children[0].value;//即要运行的代码。
var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。
newwin.opener = null // 防止代码对论谈页面修改
newwin.document.write("<title>网站制作学习网--运行代码框</title>");//新窗口title
newwin.document.write("<BODY BGCOLOR=#ffffff>")//新窗口背景颜色
newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
newwin.document.write("</BODY>")
newwin.document.close();
}
</script>
<span>
<textarea cols=95 rows=12></text_area><br>
<input type=button value=运行代码 onclick='runCode()'>
·上一篇:网络受限制或无连接 >> ·下一篇:配置oblog >>