首页 > 代码库 > 运行代码

运行代码

试一下:

<script type="text/javascript">// |[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g;var encodeHtml = function(s){return (typeof s != "string") ? s :s.replace(REGX_HTML_ENCODE,function($0){var c = $0.charCodeAt(0), r = ["&#"];c = (c == 0x20) ? 0xA0 : c;r.push(c); r.push(";");return r.join("");});};var REGX_HTML_DECODE = /&\w+;|&#(\d+);/g;var HTML_DECODE = {"<" : "<", ">" : ">", "&" : "&", " ": " ", """: "\"", "©": "?"};var decodeHtml = function(s){return (typeof s != "string") ? s :s.replace(REGX_HTML_DECODE,function($0,$1){var c = HTML_DECODE[$0]; // 尝试查表if(c === undefined){// Maybe is Entity Numberif(!isNaN($1)){c = String.fromCharCode(($1 == 160) ? 32 : $1);}else{// Not Entity Numberc = $0;}}return c;});};var html = encodeHtml(‘

  1. 测试的内容
  2. 测试的内容
  3. 测试的内容
  4. 测试的内容
‘); $(‘.runcode‘).prepend(html); function runcode(){ var win = window.open(); win.document.write(decodeHtml($(‘.runcode‘).html())); }// ]]></script>

运行代码