Skip to content
mir3z edited this page Dec 25, 2014 · 5 revisions

Overview

TextHighlighter allows you to highlight text on web pages. It can be done by selecting text manually or by automatically searching all occurrences of given phrase.

How it works?

Selected text is wrapped in span tag. I don't use execCommand("HiliteColor") or nothing like this since I found it not flexible enough.

What about old jQuery TextHighlighter?

TextHighlighter is a new and better version of jQuery TextHighlighter with some major changes. If for some reason you want to get some old versions, just look for release older than 1.2.0.

First of all I've dropped some legacy code. I realized that jQuery is no longer needed for this project so I've removed it. If you really love jQuery, I've created a short jQuery plugin wrapper. I no longer support old browser as well. Now it should work on all modern browsers and IE >= 9. If something bad happen with TextHighlighter in your browser - please let me know.

Secondly, jQuery TextHighligher was a little bit buggy. Now, all known issues should be fixed (and probably a new ones created). This means that normalization, serialization and highlighting with multiple colors should work a lot better.

And the last, but not least - a few new features has been added:

  • DOM should be much more cleaner since I've fixed issues with normalization of highlights. By "normalization" I mean process which ensures that highlighting is done with minimal possible number of span tags. Also highlights should not be nested if possible.
  • You can now find and highlight all occurrences of given search phrase. This is done with use of window.find in browsers which support it, and TextRange object in IE.
  • Obtaining existing highlights should be more meaningful now since highlights are logically grouped.

More documentation?

You can take a look at API reference or Guide section on this wiki.