Forum Moderators: open

Message Too Old, No Replies

simulating google text highlighter

anyone hack this out yet in javascript?

         

amznVibe

11:54 am on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've done a simple text highlighter in javascript but I am wondering if anyone has coded a fancy version that will do multiple colors and obey the phrase quotes etc. just like the google toolbar does?

Thanks for any help!

claus

12:32 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although you ask for JavaScript i'd just like to mention that i'm sure there's a PHP module as well as a Perl one that does just that. I just tried locating them via Google and Alltheweb but failed, but i've seen both before, so they're out there somewhere. You might also find a blogger app (in PHP) called "MT-RefSearch" interesting.

/claus

amznVibe

5:21 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well there are certain advantages to doing via javascript, including instantaneous reaction and you can analyze the elements you are toying with alot easier.

I have two ways of changing the highlights in javascript, one using textranges which works only on IE of course (well mozilla too with some modification) and the other way using innerHTML, which works on almost all of the newest versions of major browsers.

The php script you mentioned is an addon for Movabletype that takes the incoming refer from Google and highlights the words the person was searching for. Interesting but not what I want.

claus

6:15 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, i thought you wanted search terms highlighted based on the HTTP_REFERRER and not "just" plain highlighting of selected text.

I'm not sure i can help, but what exactly are the things you want do do with javascript, that it isn't doing now?

amznVibe

6:23 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is for user selected highlighting on complex pages of text, not refers (which most personal firewalls are blocking anyway these days).

I was just looking to save some time, hunting for clean code that handles multi-color for multi-words like Google does. Google also handles quoted phrase matching from the toolbar if you didn't know that. I guess I will end up hacking it out myself in the end ;)

killroy

6:35 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I had once to code one for Tedster, the deal was that the page contained several DIVs of which only one was visible at a time, and you could switch through them via tabs.

They wanted to display the correct tab where the keywords are present. So I created a JS version where you gave it an array of IDs, the text elements to consider, and an array of JS strings, code to execute when the text is found. With this it would switch automatically to th ecorrect tab and highlight the keywords.

It didn'T do quotes, but it does more then the standard plain ones...

SN