I am trying to create a highlighter in javascript that captures what text is selected and also highlights (changes text color and background). I am able to get to the point where it captures using mouseup/down (implemented using http://www.codetoad.com/javascript_get_selected_text.asp) but if I combine changing the colors (from http://www.nsftools.com/misc/SearchAndHighlight.htm), its not working and pages become unresponsive. I think since I am calling the 2nd script to change the colors from within the body tag, its not working properly. I have googled but am not able to find any solution that mixes both of the above 2 solutions.
what makes this slightly complicated is that I dont want the actions to be attached to a button, i.e. as soon as a text is selected, it should be saved in a variable and colored instantly, i.e. as soon as the mouse is lifted. I tried using CSS but it only works for the 1st highlight, i.e. as soon as you select another text, the 1st highlight is removed and the new text is highlighted....
Any help is greatly appreciated.