结合在phpwind官方论坛某朋友公布的6系列版本下可用的代码和蓝色理想的运行代码,尝试出了可以支持ie6、ie7、firefox、chrome、opera(不能复制)的运行和复制的代码(其它浏览器未测)。

js文件,保存为code.js,传论坛js文件夹:

function run_Code(code)
{
var pop = window.open('', "_blank", '');
pop.document.open('text/html', 'replace');
pop.opener = null // 防止代码对论谈页面修改
pop.document.write(code);
pop.document.close();
}
function copy_Code(obj)
{
obj.focus();
obj.select();
document.execCommand('copy');
}
function save_Code(code)
{
var pop=window.open('','_blank','top=10000');
pop.document.writeln(code);
pop.document.execCommand('saveas','','code.html');
pop.close();
}

在模板的header.htm里的</head>前加上对应的js调用:

<script language=javaScript src="js/code.js" type=text/javascript></script>

修改require/bbscode.php,找到$phpcode_htm[$codeid],连前一行一起两段改为:

code = str_replace("<br />", "<br />", code);
$phpcode_htm[$codeid]="<form><textarea name ='codeArea$codeid' rows='10' style='width:80%;'&gt;".str_replace("&lt;br /&gt;","\n",$code)."</textarea><br> <input type=button value=运行 onclick=run_Code(codeArea$codeid.value) class=btn&gt; &lt;input type=button value=复制 onclick=copy_Code(codeArea$codeid) class=btn> <input onclick=codeArea$codeid.value='' value=清除 type=button name=codeAre$codeid class=btn> <input type=reset value=恢复 name=codeAre class=btn> <font color=#AF88A1 size=-1>※ 可以先修改代码再运行</font><form>";

完成。