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>
  • 相关阅读:
    软件测试课堂练习
    JSP第一次作业
    安卓第六次作业
    安卓第五次作业
    第四次安卓作业
    JSP第四周
    软件测试课堂练习3.4
    Android数据库表
    Android购物菜单
    Android增删改查
  • 原文地址:https://www.cnblogs.com/guozhe/p/15188887.html
Copyright © 2011-2022 走看看