zoukankan      html  css  js  c++  java
  • JS实现直接运行html代码的方法

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>JS实现直接运行html代码的方法</title>
       
    </head>
    <body>
        <textarea style='300px;height:200px;' id='txtCode'></textarea><br/>
        <input type='button' value='直接运行' id='btnRun'/>
        <script>
          document.getElementById('btnRun').onclick = function(){
            var runHtml = document.getElementById('txtCode').value;
            if(runHtml){
              var win = window.open('', '运行窗口');
              win.document.open();
              win.document.write(runHtml);
              win.document.close();
            }
            else{
              alert('请输入!');
            }
          }
        </script>
    </body>
    </html>
  • 相关阅读:
    HTML5 WEB SQL
    Android-day04
    Android-day03
    Android-day02
    Android-day01
    java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
    事务管理、整合Junit、整合Web、SSH整合
    AOP、AspectJ、JdbcTemplate
    Spring基础
    Hibernate对连接池的支持
  • 原文地址:https://www.cnblogs.com/guozhe/p/15188887.html
Copyright © 2011-2022 走看看