Ted's Home Page Get Firefox! Get Thunderbird! Friday, November 15, 2024, 1:21 pm GMT
    Home :: Contact :: Blog :: Updates (Tue, Feb 12) :: Search :: Highlight Linux :: Apache HTTPD :: PHP :: VIM :: OCS
          email me email me
 
[Ted and a baby giraffe]
 
Contact Me
Résumé/CV
More Information
 
Faculty Job Search
Industry Job Search
Research/Graduate
Work
My Teaching Sites
 
General Posts
(including
LaTeX
templates)
 
Utilities
 
Public hg repos
Public git repos
 
Links
The Blog
 
Guestbook
 
 
 
 
   
 
 
  email me
email me
email me
email me


In-page Highlighting :: Using JavaScript on Client-Side



Introduction

This is an example of an alternative use of searchhi.js. See Highlighting Words from Search Results for the original use of this script and some additional details on how to customize the example below. Very little additional instructions will be provided on this page aside from this example.

Also See Slimmer Simpler Example
This example is meant to extend the features of Highlighting Words from Search Results to do an additional type of in-page highlighting. If all you want is in-page highlighting and none of the other stuff, then you should see the much slimmer example in Simple In-page Highlighting Example.
This Example

The only difference between this and the "Method 2" implementation (in the "Option 1" case) is the <form>...</form> to insert where you want the search box. Use the following instead.

<form name="searchhi" onSubmit="localSearchHighlight('?h=' + document.searchhi.h.value); return false;">

   <p>Highlight words: <input name="h" value="" /></p>

   <input type="button" value="Highlight" 
    onclick="localSearchHighlight('?h=' + document.searchhi.h.value);" />

   <input type="button" value="Remove Highlight" 
    onclick="unhighlight(document.getElementsByTagName('body')[0])" />

</form>

This will produce the following.

Highlight words:

Notice that an actual form submission is not required to trigger the highlighting. Also notice that highlighting can be turned off without a form submission. Finally, notice that the same modifications can be made to the "Option 2" case of the "Method 2" implementation if refresh toggling is desired.


 


appalling appalling
appalling appalling
email me email me
 
1701581 hits
(145 today)
 
Terms of Use
Ted Pavlic <ted@tedpavlic.com>   appalling appalling appalling appalling email me email me GPG Public Key: D/L, View, Ubuntu, MIT, PGP (verified) (ID: E1E66F7C) This Page Last Updated on Tuesday, February 12, 2019, 6:17 pm GMT