首页 > Firefox > 「Firefox」Firefox书签实现高亮选中文本

「Firefox」Firefox书签实现高亮选中文本

2009年12月1日
阅读评论 发表评论

书签实现高亮选中文本

新建书签,添加下面的代码到书签的地址

代码:

javascript:(function(){%20%20function%20highlight%20(node,%20word){%20var%20offset%20=%20node.nodeValue.lastIndexOf(word);%20while(offset%20>=%200){%20var%20range%20=%20document.createRange();%20range.setStart(%20node,%20offset%20);%20range.setEnd(%20node,%20offset%20+%20word.length%20);%20range.surroundContents(%20SPAN.cloneNode(false)%20);%20offset%20=%20node.nodeValue.lastIndexOf(word);%20}%20}%20%20var%20word%20=%20getSelection()+''%20||%20prompt('Search%20word');%20if%20(!word)%20return;%20%20var%20XPATH%20=%20'descendant::text()[contains(self::text(),%22'%20+%20word%20+'%22)%20and%20not(ancestor::option)%20and%20not(ancestor::textarea)%20and%20not(ancestor::script)%20and%20not(ancestor::style)]';%20var%20SPAN%20=%20document.createElement('span');%20SPAN.style.cssText%20=%20'background-color:#ff6;%20color:#000';%20%20var%20x%20=%20document.evaluate(XPATH,%20document.body,%20null,%207,%20null);%20for%20(var%20i%20=%200,%20len%20=%20x.snapshotLength;%20i%20<%20len;%20i++){%20var%20node%20=%20x.snapshotItem(i);%20highlight(node,%20word);%20}%20%20})();

 

你也可以使用扩展SearchWP,能把搜索栏当查找栏用的扩展

Jump-to-word buttons and highlighting for the search box content

Find terms entered in the search box easily with jump-to-word buttons and highlighting. Words typed in the search box are converted into buttons that can be used to find them in the current page.

修改默认的 关键字高亮颜色的 userChrome.css 代码

searchwp-term-highlight1 { background-color: #ffff77 ! important; }
.searchwp-term-highlight2 { background-color: #c3fffe ! important; }
.searchwp-term-highlight3 { background-color: #99ff99 ! important; }
.searchwp-term-highlight4 { background-color: #ff9999 ! important; }

 

软件集散地 http://www.my219.cn/

软件集散地 http://www.my219.cn/

软件集散地 http://www.my219.cn/

软件集散地 http://www.my219.cn/

附件下载「54 KB 」
官方原版直接安装
下载说明:「语言:中文/English」「分享者:Grayciel
1、建议购买特价正版! 勿用于商业用途!使用前先自行杀毒! 建议购买特价正版!
2、有小部分需要解压密码,请输入www.my219.cn
3、如果您下载的文件出现无法下载、解压不了或者文件受损,请选择其他下载点重新下载,资源外链不保证时效长短。

Rand Posts:

Related Posts:

作者: Grayciel 分类: Firefox 标签:
本文链接地址:[http://www.my219.cn/archives/62483]
本文分享与收藏:DeliciousQQ书签Google豆瓣校内开心新浪九点鲜果AddThis更多 »
声明:本站遵循 [署名-非商业性使用-相同方式共享 3.0] 共享协议. 转载请注明转自[软件集散地]

本站Rss订阅地址:[RSS订阅《墙内》][RSS订阅《墙外》][RSS订阅《墙外》][Rss邮箱订阅地址]

  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.