运行代码

      网页类学习笔记 2007-8-1 15:11
<script>
function runCode()  //定义一个运行代码的函数,

{
  var code=event.srcElement.parentElement.children[0].value;//即要运行的代码。
  var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
  newwin.opener = null // 防止代码对论谈页面修改
  newwin.document.write(code);  //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
  newwin.document.close();

}
</script>
<span><textarea  cols=95 rows=12> </textarea><br><input type=button value=运行代码 onclick='runCode()'>

标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}