ASP网站搜索关键高亮代码

来源:百度知道 编辑:UC知道 时间:2024/06/07 21:58:41
我想在网站的搜索结果页面加入高亮关键字功能,在网上找了很多段代码,不知道怎么用,请给我一段完整好用的代码,并附上使用方法,我的搜索关键字变量是“keyword”,谢谢大家!
还是不明白怎么用,把我的搜索页面的代码贴出来,麻烦帮我改一下,万分感谢!
---------------------------------------------------------
<%dim m,n,keyword,searchsl
keyword=request("keyword")
searchsl=request("searchsl")

if searchsl = "1" then
exec="select * from info where topic like '%"&keyword&"%' and state = 1 order by id Desc"
else
exec="select * from info where content like '%"&keyword&"%' and state = 1 order by id Desc"
end if
'----------------------------------------------------------------------------------------------------
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
rs.pagesize=40
tatalrecord=rs.recordcount
tatalpages=rs.pagecount

<tr>

<%
Dim keyword,str

keyword="网"
str="我想在网站的搜索结果页面加入高亮关键字功能,在网上找了很多段代码"
str=Replace(str,keyword,"<font color='red'>"&keyword&"</font>")

response.write str
%>

上面是直接用VBS里边的一个replace函数,处理小量内容还行~

如果要处理大量内容,最好用正则表达式