关键词高亮 本帖最后由 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);最后所以匹配到的东西都会有下划线的!! 如何将C#加密算法换算成PHP算法(懂C#和PHP大鸟请进) php+apche+mysql php将字符类型的数字转换成数值类型,数字可能是带小数点的。 怎么才能将MYSQL语句 导到一个文本文件中。或将一个文本文件中的SQL语导入MYSQL中并执行呢? 唠叨老大还在么?XML解析出错求助,5555 关于图片缓存的问题 php文件下载乱码问题 【求助】PHP判断FTP是否连接成功 关于PHP和Ajax的问题 菜鸟问:关于php简单问题!!! 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 搜索是高亮啊