改变指定文字的颜色

hnck 2006-05-20 12:04:48
从数据库中提取出数据(文字)并显示,如何改变所显示的文字中指定文字的颜色?
例如:使用百度搜索出数据后,搜索后显示页面中的关键字的颜色会变成红色,或其它颜色
...全文
109 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2006-05-20
  • 打赏
  • 举报
回复
Dim i
i = 1
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
With Response
Set rs = cn.Execute(strSQL)
While Not rs.EOF
strTitle = rs("DTitle")
If blnPost Then
regEx.Pattern="(("& Request("keyWord") &"))"
strTitle = regEx.Replace(strTitle,"<font color='#ff0000'>$1</font>")
regEx.Pattern="(("& Request("keyWord2") &"))"
strTitle = regEx.Replace(strTitle,"<font color=""#ff0000"">$1</font>")
Else
regEx.Pattern="(("& Request("keyWord") &"))"
strTitle = regEx.Replace(strTitle,"<font color='#ff0000'>$1</font>")
End If
If i Mod 2 = 1 Then
.Write "<tr onmouseover=""this.bgColor='#C1D2EE'"" bgcolor='#FFFFFF' onmouseout=""this.bgColor=document.getElementById('DataGrid1').singleValue"">"
Else
.Write "<tr onmouseover=""this.bgColor='#C1D2EE'"" bgcolor='oldlace' onmouseout=""this.bgColor=document.getElementById('DataGrid1').oldValue"">"
End If
.Write "<td><a target='_blank' href='ShowDetail.asp?id=" & rs("objectGuid") & "'>" & strTitle & "</a></td><td><a target='_blank' href='ShowList.asp?id=" & rs("id") & "'>" & rs("STitle") & "</a></td><td>" & rs("CreateDate") & "</td></tr>"
rs.MoveNext
i = i + 1
Wend
rs.Close
Set rs = Nothing
End With
slawdan 2006-05-20
  • 打赏
  • 举报
回复
娘子,跟牛魔王出来看上帝啊!

百度的应该是用客户端JS实现的~

最后,再拜一拜1楼~

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧