'==================================================
'函数名:showbold
'作 用:搜索关键字显示红色(多关键字)
'参 数:theField,keywords
'==================================================
function ShowBold(theField,keywords)
if instr(keywords," ")<>0 then
str=split(keywords)
str_count= ubound(str)
for i=0 to str_count
if str(i)<>"" then
'response.Write str(i)&"<br>"
if showbold="" then
ShowBold=replace(theField,str(i),"<font color=red>"&str(i)&"</font>")
else
ShowBold=replace(ShowBold,str(i),"<font color=red>"&str(i)&"</font>")
end if
'response.Write "<br>a"&ShowBold&"<br>"
end if
next
else
ShowBold=replace(theField,keywords,"<font color=red>"&keywords&"</font>")
end if
end function
还要解决的一个问题就是遇到中文空格。可以在关键字前加入
keywords=replace(keywords," "," ")
注意:前面的一个空格是中文空格,后面是半角空格。