IntroductionBoth* Highlighting Words from Search Results with JavaScript* In-page Highlighting with JavaScriptshow examples of the JavaScript in searchhi.js that highlight words on a page. In both cases the script can be used to highlight words selected by a text field in a form on the page. However, because the script was originally intended for more advanced purposes, the configuration also has the script doing other things in the background that may not be needed by some people.
Here I show how to use searchhi.js in a much slimmer way to do vanilla client-side in-page word highlighting. However, some people may be more comfortable with something even slimmer, so here I also introduce searchhi_slim.js and the way to use it for very slim and very simple client-side JavaScript highlighting.
The end goalhe goal is to setup a form like the one below that searches through a document for some words and highlights them with some special background color. Note that if you refresh your webpage, the highlighting will disappear just as if you had selected "Remove Highlight."
Highlight words:Using searchhi.js in a slim way āēūīThen, somewhere in the < of your document, place a search form similar to the following that you can leave out any of these buttons and change any of the textThis should achieve the goal. Using the always slim searchhi_slim.jsFirst, setup your highlighting color and include the script. Add the following lines to your section. If you download the script yourself, change the line to point to wherever you put the script.
SPAN.searchword { background-color:yellow; }src="http://links.tedpavlic.com/js/searchhi_slim.js" type="text/javascript" languageThen, somewhere in the of your document, place a search form similar to the follo can leave out any of these buttons and change any of the text) (note that the syntax here is slightly different from the syntax above. A number of '?h=' have been left out in this slim version.This should achieve the goal. Concern: Microsoft Incompetence and Microsoft Internet Explorer
IntroductionBoth* Highlighting Words from Search Results with JavaScript* In-page Highlighting with JavaScriptshow examples of the JavaScript in searchhi.js that highlight words on a page. In both cases the script can be used to highlight words selected by a text field in a form on the page. However, because the script was originally intended for more advanced purposes, the configuration also has the script doing other things in the background that may not be needed by some people.
Here I show how to use searchhi.js in a much slimmer way to do vanilla client-side in-page word highlighting. However, some people may be more comfortable with something even slimmer, so here I also introduce searchhi_slim.js and the way to use it for very slim and very simple client-side JavaScript highlighting.
The end goalhe goal is to setup a form like the one below that searches through a document for some words and highlights them with some special background color. Note that if you refresh your webpage, the highlighting will disappear just as if you had selected "Remove Highlight."
Highlight words:Using searchhi.js in a slim way āēūīThen, somewhere in the < of your document, place a search form similar to the following that you can leave out any of these buttons and change any of the textThis should achieve the goal. Using the always slim searchhi_slim.jsFirst, setup your highlighting color and include the script. Add the following lines to your section. If you download the script yourself, change the line to point to wherever you put the script.
SPAN.searchword { background-color:yellow; }src="http://links.tedpavlic.com/js/searchhi_slim.js" type="text/javascript" languageThen, somewhere in the of your document, place a search form similar to the follo can leave out any of these buttons and change any of the text) (note that the syntax here is slightly different from the syntax above. A number of '?h=' have been left out in this slim version.This should achieve the goal. Concern: Microsoft Incompetence and Microsoft Internet Explorer