JavaScript/DHTML/Greasemonkey

Soldato
Joined
26 Nov 2003
Posts
4,656
Location
Brentwood
Hey guys,

Wonder if you can help me, looking for a basic text highlighter. With the search queries in an array.

So eg;

1. Eggs
2. Bacon
3. Ham

So, any matches to the array entries are highlighted on a page.

Cheers.
 
HI

download the script and include it in your html

http://fucoder.com/code/se-hilite/

then place this in your html , you need to find a way of producing the keywords to highlight, ive just hardcoded them below

Code:
<script type = "text/javascript">
var keywords = new Array("egg","cheese","bacon");
Hilite.hiliteElement(document.body,keywords);
</script>

Then in your css style sheet, define some classes for the colours of the highlight

.highlight1{background:xxx}
.highlight2{background:xxx}
.highlight3{background:xxx}
.highlight4{background:xxx}
.highlight5{background:xxx}

if you have any troubles just post them and il answer
 
Thanks for your reply, it won't be in html as its for greasemonkey.

But I think I can work it out from here.
 
Back
Top Bottom