运行文本域代码功能
分类:电脑知识 发表于:2010-07-28 10:44:24 评论(0)
=============
JS部分
=============
<script language="JavaScript" type="text/JavaScript">
function runEx(cod1) {
cod=document.all(cod1)
var code=cod.value;
if (code!=""){
var newwin=window.open('','',''); //打开新窗口
newwin.opener = null // 防止代码对页面修改
newwin.document.write(code); //向新窗口中写入代码
newwin.document.close();
}
}
</script>
=============
文章中引用
=============
<textarea id="run01" name="textarea" rows="10" cols="60"></textarea><br>
<input style="cursor: hand" onclick="runEx('run01')" type="button" value="运行代码">