您的位置:首页 > Web前端 > HTML

运行html代码

2015-07-17 21:18 579 查看
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题</title>
<script language="JavaScript" type="text/JavaScript">
//运行文本域代码
function runEx(cod1)  {
cod=document.all(cod1)
var code=cod.value;
if (code!=""){
var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
newwin.opener = null // 防止代码对论谈页面修改
newwin.document.write(code);  //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
newwin.document.close();
}
}
</script>

</head>
<body>
<textarea name="textarea" cols="90" rows="14" id="rn01">加入要运行的代码</textarea>
<INPUT onClick="runEx('rn01')"  type="button" class="toolsmtbtn" value="运行代码" style="cursor:hand">
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: