Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / How does Google do it?!?

Author
Message
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 4th Jun 2013 07:54
I've noticed that in Google search results, they do something very interesting.
try this:
go to Google
type in anything
hover your mouse over one of the links
it comes up as www.foobar2000.org
middle click on it
it changes to http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCwQFjAA&url=http%3A%2F%2Fwww.foobar2000.org%2F&ei=O3KtUZPHE4PliAfr04GQBg&usg=AFQjCNGQknEqVa-v5EXzIMs9jCwNJ8VU2w&sig2=UxObhEf1jzGs0GTWX0mltg
which then directs you to www.foobar2000.org


how?
how do they change it?!?!? (my guess is Javascript, but I'm too lazy to check the page source), ok that's not entirely true, but I took one look at it and decided to see if anyone else knew

mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Jun 2013 09:04 Edited at: 4th Jun 2013 09:05
I hate that thing, sometimes it's just not redirects to the real site! Hatehatehate

«Just because you’re unique, doesn’t mean you’re useful»
«If you contributed to the reason for locking, you may now find yourself on moderation, or in extreme cases in the grave»
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 4th Jun 2013 10:22 Edited at: 4th Jun 2013 10:22
Maybe something like this simple redirect-code (in this case it would take 5 seconds to redirect):



And maybe on their HTML document load they do some tracking of your action via script (before it redirects).

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Jun 2013 10:34
Most likely javascript. If you disable JS and try it again, I think you'll see it doesn't do that anymore.

Also, if you look at the page source code for google, you'll see a huge amount of javascript.

kaedroho
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 4th Jun 2013 11:19 Edited at: 4th Jun 2013 11:24
I'm not sure how they change the popup which says which URL you're supposed to go to, thats probably some javascript stuff

That is a spoof though, the actual link in the search results links to a weird Google url page (on Googles website). When this page opens, google simply sends you a HTTP 307 Redirect that tells your browser to go to www.foobar.com

The most likely reason for this is so they know what search result you pressed. This is handy for them for a couple of reasons: They can track where you go - which helps them choose better ads based on what sites you visited. Also, it helps them to find which search results are most popular so they put them higher on the list




As an example, to implement that special URL redirect page in PHP, you would simply do:


Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 4th Jun 2013 16:12
They also use an intermediate link so that the site can't see what you were searching to find it - iirc.


They see me coding, they hating. http://indi-indicium.blogspot.co.uk/
BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 4th Jun 2013 19:58
In javascript you can do:
window.location = "new url";

But its most likely server side!

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 4th Jun 2013 20:22 Edited at: 4th Jun 2013 20:22
One of the things I wonder is how it makes the status bar (the thing at the bottom) show the redirect address, rather than the actual address.

"Sideboobs are awesome. Getting punched in the face is not." - Jerico2Day on violence and nudity
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Jun 2013 20:35
@Benjamin
Actually if you click the link once, then the real one will be shown.

«Just because you’re unique, doesn’t mean you’re useful»
«If you contributed to the reason for locking, you may now find yourself on moderation, or in extreme cases in the grave»
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 4th Jun 2013 21:43
Quote: "Actually if you click the link once, then the real one will be shown."


But that takes you to another page, and doesn't give you the chance to see the real link before it takes you there.

"Sideboobs are awesome. Getting punched in the face is not." - Jerico2Day on violence and nudity
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 5th Jun 2013 00:47
Quote: "But that takes you to another page, and doesn't give you the chance to see the real link before it takes you there."

Middle-click? Shift+click?

«Just because you’re unique, doesn’t mean you’re useful»
«If you contributed to the reason for locking, you may now find yourself on moderation, or in extreme cases in the grave»
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 5th Jun 2013 02:27
Middle click just opens the page in a new tab (Chrome).

"Sideboobs are awesome. Getting punched in the face is not." - Jerico2Day on violence and nudity
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 5th Jun 2013 03:33
Yes, and...?

«Just because you’re unique, doesn’t mean you’re useful»
«If you contributed to the reason for locking, you may now find yourself on moderation, or in extreme cases in the grave»
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 5th Jun 2013 03:47
Quote: "One of the things I wonder is how it makes the status bar (the thing at the bottom) show the redirect address, rather than the actual address."


"Sideboobs are awesome. Getting punched in the face is not." - Jerico2Day on violence and nudity
Jimpo
20
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 5th Jun 2013 08:35
Check out this discussion:
http://stackoverflow.com/questions/3573942/html-override-statusbar-link-location-display

Looking at Google's source code, they implement something similar to the second solution discussed there:


Here is the similar code used on Google's page:


It seems like when you mouse down on the link, it calls a function that changes it to the proper url.

easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 5th Jun 2013 08:42
interesting, it's a good thing email is html only, no Javascript, otherwise spammers/phishers would have a field day!

Login to post a reply

Server time is: 2025-05-15 16:25:58
Your offset time is: 2025-05-15 16:25:58