<div class="codetitle"> <span><a style="CURSOR: pointer" data="29470" class="copybut" id="copybut29470" onclick="doCopy('code29470')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code29470"> <br> <br> <br> <br><meta charset="utf8"> <br><title>网页中的运行代码功能</title> <br><script type="text/javascript"> <BR>function runCode(oCode) { <BR>var win = window.open('', "_blank", ''); <BR>win.document.open('text/html', 'replace'); <BR>win.opener = null <BR>win.document.write(oCode.value); <BR>win.document.close(); <BR>} <BR></script> <br> <br> <br><textarea id="code1" rows="10" cols="95"> <br> <br> <br> <br><meta charset="utf8"> <br><title>测试文档</title> <br> <br> <br>测试文档 - 你可以先修改部分代码再运行 <br><script>alert('hello')</script> <br> <br> <br></textarea> <br><br> <br><input type="button" value="运行代码" onclick="runCode(code1)"> <br> <br> <br> </div>