仿蓝色理想的“运行代码”功能

来源:互联网 发布:英国经济数据查询网站 编辑:程序博客网 时间:2024/04/28 14:30

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>RunCode Example</title>
<script>
function runCode(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="RunCode1" style="width:274; height:167">
<b>Welcome to Betty's Blog:</b><br>
<a href="http://blog.csdn.net/cutebab0888">
http://blog.csdn.net/cutebab0888</a><BR></textarea><br><BR>
<INPUT name="button" type=button onclick=runCode(RunCode1) value="运行代码">