关键词高亮 本帖最后由 zfm1988 于 2011-06-11 22:22:41 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个很容易啊,用js现实最好<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><body>hello world,every thing is wrong</body><script> function HighLight(nWord){ if(nWord!=''){ var keyword = document.body.createTextRange(); while(keyword.findText(nWord)){ keyword.pasteHTML("<span style='color:red;'>" + keyword.text + "</span>"); keyword.moveStart('character',1); } } } function highword(nWord){ var array = nWord.split(","); for(var i=0;i<array.length;i++){ HighLight(array[i]); } } HighLight('hello')</script></html> 你这只是一种特例,你想想在一篇文章中,让指定都文字高亮,你着可以实现吗??就 google 搜索是高亮啊 呵呵,说说我的思路吧!!首先通过一个usort()函数,将数组安装内容长短,从大到小的排序,然后再通过preg_replace("/\b("word")\b/", '<u>\\1</>,$str);最后所以匹配到的东西都会有下划线的!! 不间断读取并解压gzip数据流 @符号在php中的做用 这个cookie好奇怪!@ 求个正则 php新手问题,关于mysqli 什么算是"对PHP的某一方面有深入理解",欢迎讨论,恳求见解 如何把数组中的数据以表格的形式显示,数组一位的且长度可知但不顾定。--用php 又一个下拉列框问题,急!!! PHP写一个对服务器文件的管理程序! preg_replace改写preg_replace_callback的问题 php header() 以及 apache ErrorDocument 404 关于rewrite网址转向,可不可以指定一个不转,其它的都转?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
hello world,every thing is wrong
</body>
<script>
function HighLight(nWord){ if(nWord!=''){ var keyword = document.body.createTextRange(); while(keyword.findText(nWord)){ keyword.pasteHTML("<span style='color:red;'>" + keyword.text + "</span>"); keyword.moveStart('character',1); } } } function highword(nWord){ var array = nWord.split(","); for(var i=0;i<array.length;i++){ HighLight(array[i]); } }
HighLight('hello')
</script>
</html>
你这只是一种特例,你想想在一篇文章中,让指定都文字高亮,你着可以实现吗??就 google 搜索是高亮啊