CSDN博客

img y97523szb

给你的blog代码加高亮

发表于2004/7/16 9:27:00  914人阅读

分类: 程序人生

根据你常用的语言替换掉关键词,将下列代码直接复制到你的静态新闻中即可

<script language="javascript">
var doc;
function load()
{
var els=document.getElementById("main").document.getElementsByTagName("DIV");
for(var ii=0;ii<els.length;ii++){
if(els[ii].className=="postText"){
doc=els[ii].innerHTML;
els[ii].innerHTML=op(doc);
}
}
}
document.onload=setTimeout("load()",2000);
</script>

<script language=vbscript>
function op(doc)
dim ok
Dim regEx, Match, Matches

Set regEx = New RegExp
regEx.IgnoreCase = true
regEx.Global = True

keywordblue="else if,elseif,end if,if,len,for,then,true,false,version,each,in,class,set,d ,while,loop,nothing,server,sin,request,response,next,mid,left,right,rightb,leftb,midb,write,close"
keywordred="server,createobject,close,session,application,name,vbcrlf,recordset,connection,command,recordcount,count,item"

keywordblue=replace(keywordblue,"<","&lt;")
keywordblue=replace(keywordblue,">","&gt;")
keywordred=replace(keywordred,"<","&lt;")
keywordred=replace(keywordred,">","&gt;")

arrblue=split(keywordblue,",")
arrred=split(keywordred,",")


for i=0 to ubound(arrblue)
regEx.Pattern = "/b("&arrblue(i)&")/b|/n"
ok="<font color=blue>$1</font>"
doc = regex.replace(doc,ok)
next

for i=0 to ubound(arrred)
regEx.Pattern = "/b("&arrred(i)&")/b"
ok="<font color=red>$1</font>"
doc = regex.replace(doc,ok)
next

doc=replace(doc,chr(34)&chr(34),"""")
regEx.Pattern = chr(34)&"(.+?)"&chr(34)
set Matches = regEx.execute(chr(34)&"(.)"&chr(34))
for Each match in Matches
doc = regEx.replace(doc,chr(34)&"<font color=green>$1</font>"&chr(34))
next
set regEx = nothing
doc= replace(doc,"""",chr(34)&chr(34))
op = doc
end function
</script>
0 0

相关博文

我的热门文章

img
取 消
img