首页 > Web开发 > 详细

运行html代码

时间:2015-07-17 22:36:30      阅读:379      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!