代码运行插件, ,直接运行浏览效果PHPWind7.5
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($code)这个函数替换成下面这段代码:
function phpcode($code){
global $phpcode_htm,$codeid;
$code = str_replace(array(\"[attachment=\",\\\\\"),array(\"[attachment=\",\"),$code);
$codeid ++;
$code = preg_replace(/^(<br \\/>)?(.+?)(<br \\/>)$/,\\\\2,$code);
$code = str_replace(\"<br />\", \"<br />\", $code);
$phpcode_htm[$codeid]=\"<form><textarea name =codeAreacodeid rows=10 style=width:80%;>\".str_replace(\"<br />\",\"\\n\",$code).\"</textarea><br> <input type=button value=运行 onclick=run_Code(codeAreacodeid.value) class=btn> <input type=button value=复制 onclick=copy_Code(codeAreacodeid) class=btn> <input onclick=codeAreacodeid.value= value=清除 type=button name=codeArecodeid class=btn> <input type=reset value=恢复 name=codeAre class=btn> <font color=#AF88A1 size=-1>※ 可以先修改代码再运行;支持ie和firefox浏览器。</font><form>\";
return \"<\\twind_phpcode_$codeid\\t>\";
}
提示: (暂时可以不用,再完善后再发上来,现在好像兼容性不好,在有的浏览器上不能运行.)待修改完善后再发上来.
页:
[1]