实现蓝色理想的"运行代码"

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

效果如下,代码在下面:

代码:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>新建网页 1</title>

</head>

<body>

<script>

function runCode() //定义一个运行代码的函数,

{

var code=RunCode.value;//要运行的代码,即textarea的内容,RunCode是textarea的name。

var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。

newwin.opener = null // 防止代码对页面修改

newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。

newwin.document.close();

}

</script>

<textarea name="RunCode" style="width:274; height:167">

<b>Welcome to C's Blog:</b><br>

<a href="http://blog.csdn.net/catally">http://blog.csdn.net/catally</a>

</textarea><br>

<INPUT name="button" type=button onclick=runCode() value=运行代码>

</body>

</html>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航