首先定义个文本域并且给个ID
<textarea id="O_txt_1" rows="8" cols="80"> <!--要运行的代码--> </textarea>
然后定义个按钮
<input type="button" value="运行代码" onclick="runCode('O_txt_1')" />
最后当然是要写函数了,代码如下:
复制代码 代码如下:
function runCode(id){
var obj=document.getElementById(id);
var win = window.open('', "_blank", '');
win.document.open('text/html', 'replace');
win.opener = null;
win.document.write(obj.value);
win.document.close();
}
标签:
运行代码

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“cnblogs 运行代码功能尝试”

暂无“cnblogs 运行代码功能尝试”评论...