Page 1 of 1

Google search terms highlighted within result pages

Posted: Tue Aug 22, 2006 2:08 am
by Luke
I just typed "test driven development in php" into google, and when I clicked on the second result, it took me to this page:
http://blog.casey-sweat.us/?p=49

Now on this page, "test", "driven", "development", "in" and "php" were highlighted. How in the world is this accomplished?

Source code on the page looks like this... so this is accomplished server side??

Code: Select all

<p>Here is the <span class="hilite">Test</span> <span class="hilite">Driven</span> <span class="hilite">Development</span> <span class="hilite">in</span> PHP presentation from <span class="hilite">php</span>|tropics.  You can download either the <a href="img/phpt_tdd.zip">zip</a> or <a href="img/phpt_tdd.tgz">tarball</a> flavors.  <span class="hilite">In</span> each is the PowerPoint presentation and the code files with unit tests I used when writing the presentation.</p>
EDIT: I just realized this is sweatje's blog... so maybe he can answer this for me.

Posted: Tue Aug 22, 2006 2:26 am
by pedrotuga
very simple.

1.check if the user comes from google/yahoo/live.com/whatever
2. if so get the search words from the referer
3. replace every ocorrence of keyword string by "<span class="hilite">Keyword</span>"

there ya go

Posted: Tue Aug 22, 2006 2:27 am
by Luke
hmm... yea that is simple :oops: thank you :D

Posted: Tue Aug 22, 2006 2:57 am
by shiznatix
i find that very annoying. please dont put that on any of your websites

Posted: Tue Aug 22, 2006 3:03 am
by pedrotuga
I personaly dont see soooo much of a use for it... one can allways press ctrl+F.
But i guess is a mater of traffic you want to get. If you want traffic the recipit, despite hard to implement, is very simple: make you page usable for the stupidest audince you can imagine.

Posted: Tue Aug 22, 2006 10:02 am
by Luke
I don't plan on using it (as I find it sort of annoying too) but I still wanted to know how it's done (to put in my arsenal)