码迷,mamicode.com
首页 > Web开发 > 详细

运行html代码

时间:2015-07-17 22:38:47      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

<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>

 

运行html代码

标签:

原文地址:http://www.cnblogs.com/casum/p/4655716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!