View Full Version : Can one highlight a table cell as a result of google search

03-19-2009, 11:54 AM

is it possible to highlight a TABLE-CELL instead of the searched word within that cell as a result of a google search.


03-19-2009, 01:57 PM
highlight a TABLE-CELL instead of the searched word within that cell as a result of a google search Sorry, it's not clear.

03-19-2009, 10:23 PM
if I look for something thru "Google Search" and then press the "in Cache" link,
then the searched words on the linked page would be highlighted.

Now....is there a JS out there which can recognise, that when a user visits my site, that the word he was searching for, is also going to be highlighted-from-google once my site is opened.

If yes could a JS highlight the Table-cell where that word would be on my page according to the colors of the highlighted words from google.

that was hard

03-19-2009, 11:03 PM
you can, though not with javascript.

you would need to get the referrer in the header from the browser on your server. for PHP it is $_SERVER['HTTP_REFERER']. from that you would need to parse the url and write code that would highlight any keywords in the google query on the pages you output to the browser. not difficult at all.


03-19-2009, 11:29 PM
thx leon
but I am not using php, so theres only the html/css or java left


03-19-2009, 11:41 PM
Actually, after looking around about this... you can use the following in javascript to get the address an user came in from:


After that, it's just a matter of parsing that string and getting the information about the keywords used. Keep in mind, it might not work all that great in all browsers, but it should work.

03-21-2009, 01:28 PM
hello Eldarrion, THX

Fistly: I do not have a clue how to implement a JS in a website.

Secondly: I have found this oner the net:

function getkeywords() {
var x = document.referrer;
var lastparturl = 0;
if (x.search(/google/) != -1) {
lastparturl = x.indexOf("&btnG=Google+Search");
x = x.slice(38,lastparturl);
x = x.concat("via google");
else if (x.search(/yahoo/) != -1) {
lastparturl = x.indexOf("&ei=UTF-8&iscqry=&fr=sfp");
x = x.slice(63,lastparturl);
x = x.concat("via yahoo");
else if (x.search(/ask.com/) != -1) {
lastparturl = x.indexOf("&search=search&qsrc=0&o=0&l=dir");
x = x.slice(25,lastparturl);
x = x.concat("via ask");
else if (x.search(/dogpile/) != -1) {
lastparturl = x.indexOf("/1/417/TopNavigation/Relevance/iq=true/zoom=off/_iceUrlFlag=7?_IceUrl=true");
x = x.slice(46,lastparturl);
x = x.concat("via dogpile");
else if (x.search(/altavista/) != -1) {
lastparturl = x.indexOf("&kgs=1&kls=0");
x = x.slice(48,lastparturl);
x = x.concat("via altavista");
else {
x = "no keywords available";
x = x.replace(/+/, " ");
return x;

could you show me please how to EXACTLY implement this on my website?