Search code examples
ajaxgoogle-searchhttp-referer

How does Google Instant change the referer sent by the browser?


If you click on a result in Google Instant, the referer sent by your browser to the destination website contains a bunch of parameters, including the all important q=[autocompleted query]

But you're coming from a page whose URL is simply http://www.google.com/ with a bunch of stuff after the # character, i.e. as an on-page anchor.

So the browser appears to be sending a URL as the referer which is different from the URL of the page that you were viewing when you clicked.

There doesn't seem to be an additional redirection, so how on earth do they do that?


Solution

  • Most of the time, a Google search result actually sends you to a Google redirect page rather than directly to the target page. They use JavaScript to switch the target of the link onmousedown as you click on it.

    You can see this effect by click-and-holding on the search result link and watching your status bar.

    This isn't specific to Google Instant, they've been doing it for quite a long time on their standard results pages.