首页 > 代码库 > [JavaScript] js实现简单的代码运行框

[JavaScript] js实现简单的代码运行框

<script type="text/javascript">// <![CDATA[ function runCode(obj) { var winname = window.open(‘‘, "_blank", ‘‘); winname.document.open(‘text/html‘, ‘replace‘); winname.document.write(obj.value); winname.document.close(); }// ]]></script><p> <textarea rows="10" id="code1" style="width: 80%;"> 这里是要输入的内容</textarea><br /> <input onclick="runCode(document.getElementById(‘code1‘))" value="http://www.mamicode.com/运行" type="button" /></p>