<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> <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> </div>