views:

140

answers:

4

in the recent past i’ve noticed quite often that, when searching something with google and looking at one of the search results, that the search terms are bold on the site.

how can this be done? is it a feature of google which is messing around with other sites (i hope not!) or are some sites parsing the referrer and check for search engine links and try to hilight the search terms?

i’m curious for the answers

+2  A: 

You have to look into http referrer http server variable, there You will find URL where user comes from.

Rafal Ziolkowski
+2  A: 

I believe you can look in the HTTP headers for the referrer (i.e. the previous URL visited). If your visitor arrived from Google, that will be the URL of the search page. Sending this header is a feature of most web browsers and it's useful for things like this. As Google search results are GET queries, a standard referrer url looks like:

http://www.google.com/search?q=stack+overflow

You can parse these out to get the query terms and format appropriately using server side script. I'm sure there's a library to do this, but it wouldn't be hard to write one.

Joe
+4  A: 

That feature works by looking at the http referer header sent by browser. This post should explain how it work: http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/

silent
your provided link doesn’t mention the referer header once
knittl
A: 

after googling around for a while i found a plugin for phpBB.

it can be found in their forums: http://www.phpbb.com/community/viewtopic.php?f=69&t=784615

it will take all popular search engines into account and hilight the search terms in the forum. reading the plugin is a great source of information

knittl