JS Runcode运行网页上的HTML/CSS/Javascrip代码
<div id="cnblogs_post_body"><div class="cnblogs_Highlighter"><!DOCTYPE html><html><head><meta charset="gb2312" /><title>runcode-运行HTML/CSS/Jvascrip代码</title></head><body><form> <textarea name="codearea" style="width:800px; height:600px"> </textarea> <br /> <input name="run" type="button" value="运行代码"></form><script>(function(){function run(code){var newWin = window.open("", "_blank", "");newWin.opener = null; // 防止代码对页面修改newWin.document.open();newWin.document.write(code);newWin.document.close();}//遍历页面中运行代码按钮varexecutes = document.getElementsByName("run");for(var i=0; i<executes.length; i++){executes.onclick = function(){var code = this.form.codearea.value;run(code);};}}());</script></body></html>
页:
[1]