给blog加上运行代码功能
2018-09-06 12:28
  在和尚那里看到他给z-blog加上了运行代码功能,放了几天假,有些怕怕再这样闲下去会生锈的,在补了一个半小时的觉之后,也给blog加上运行功能,因为是从L-Blog修改而来,因此同样适用于L-Blog,另外,FBS也是L-Blog修改而来,应该也可以使用本文中的方法来添加运行代码功能。另外,由于复制代码和保存代码还没有找到兼容各浏览器的解决方法,就没有加进来了。 
示例: 
步骤如下: 
1.在include/common.js中添加如下代码: 
复制代码 代码如下: 
functionrunCode(codeobjid){ 
varcodeobj=document.getElementById(codeobjid) 
varcodestr=codeobj.value; 
if(codestr!=){ 
varcodewin=window.open(,,); 
codewin.document.open(text/html,replace); 
codewin.opener=null 
codewin.document.write(codestr); 
codewin.document.close(); 
} 
} 
2.在include/ubbcode.asp中找到strContent=re.Replace(strContent,【code】)(把【】换成[]),在此之后添加如下代码: 
L-Blog: 
复制代码 代码如下: 
re.Pattern=\[html\](<br>)+ 
strContent=re.Replace(strContent,【html】) 
FBS: 
复制代码 代码如下: 
re.Pattern=\[html\](<br/>)+ 
strContent=re.Replace(strContent,【html】) 
再找到re.Pattern=\[code\](.*?)\[\/code\],然后在段代码的SetstrMatches=Nothing之后添加如下代码: 
复制代码 代码如下: 
re.Pattern=\[html\](.*?)\[\/html\] 
SetstrMatches=re.Execute(strContent) 
ForEachstrMatchInstrMatches 
RNDStr=Int(7999*Rnd+2000) 
tmpStr1=strMatch.SubMatches(0) 
strContent=Replace(strContent,strMatch.Value,<textarearows=10_ 
&style=width:90%;class=input_borderid=HTML_&RNDStr&>_ 
&tmpStr1&</textarea><br/>_ 
&<inputtype=buttononclick=runCode(HTML_&RNDStr&);value=运行代码/>_ 
&[Ctrl+A全部选择提示:你可先修改部分代码,再按运行]) 
Next 
SetstrMatches=Nothing 
3.修改完成,在发表日志时就可以使用【html】要运行的代码【/html】(将【】替换成[])来使用运行代码功能。 
下一篇:ASP中如何执行存储过程?