zoukankan      html  css  js  c++  java
  • 【备忘】cnblogs 插 HTML demo

    使用 HTML 源码编辑模式,贴近下面代码

    <p>
    <textarea id="ecalfCodes" style="margin: 2px;  703px; height: 415px;" rows="8" cols="80"> 
    
    //这里是转换尖括号之后的DEMO源代码
     
    </textarea>
    </p>
    <p><input onclick="runCode('ecalfCodes')" type="button" value="运行代码" /></p>
    
    <script type="text/javascript">// <![CDATA[
    function runCode(id){
    var obj=document.getElementById(id);
    var win = window.open('', "_blank", '');
    win.document.open('text/html', 'replace');
    win.opener = null;
    win.document.write(obj.value);
    win.document.close();
    }
    // ]]></script>

    然后 将 demo 页面的源代码中的尖括号转换成 实体符。

    document.documentElement.innerHTML.replace(/\<|\>/g,function(s){ return '&#'+s.charCodeAt(0)+';'; })
    
    //得到的字符串没有 <HTML>和DOCTYPE 声明标签
  • 相关阅读:
    HWOJ之纠结的优化
    java中的对象数组
    短路特性的运用
    归并排序
    两个有序数列的合并
    java中的注释规范
    堆排序
    堆的建立
    希尔排序
    直接插入排序
  • 原文地址:https://www.cnblogs.com/ecalf/p/2815066.html
Copyright © 2011-2022 走看看