欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  1、实例代码:
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset='utf-8'/>
 
  <title>直接运行html代码</title>
 
  </head>
 
  <body>
 
  <textareastyle='width:300px;height:200px;'id='txtCode'></textarea><br/>
 
  <inputtype='button'value='直接运行'id='btnRun'/>
 
  <script>
 
  document.getElementById('btnRun').onclick=function(){
 
  varrunHtml=document.getElementById('txtCode').value;
 
  if(runHtml){
 
  varwin=window.open('','运行窗口');
 
  win.document.open();
 
  win.document.write(runHtml);
 
  win.document.close();
 
  }
 
  else{
 
  alert('请输入!');
 
  }
 
  }
 
  </script>
 
  </body>
 
  </html>






本文转载自中文网
 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html5/h54969.shtml