[英]How does Google set the HTTP Referrer when someone clicks on a search result link?
Google sets a HTTP Referrer when someone clicks on a search result link. 当有人点击搜索结果链接时,Google会设置HTTP推荐者。 This referrer is different to the address which is shown in the URL address bar (eg it contains the GET parameter cd which indicates the search result position of the clicked link). 此引用者与URL地址栏中显示的地址不同(例如,它包含GET参数cd,其指示所单击链接的搜索结果位置)。
It seems that this is done with javascript. 看来这是用javascript完成的。 I would like to do something similar on my website, so I would be interested to know how exactly this "referrer manipulation" can be done with javascript. 我想在我的网站上做类似的事情,所以我很想知道这个“引用者操纵”是如何用javascript完成的。
Any ideas? 有任何想法吗?
Google redirects you through its own click-proxy when you click on its result links - the address of the proxy is what you see in Referer
. 当您单击其结果链接时,Google会通过自己的Click-proxy重定向您 - 代理的地址就是您在Referer
看到的。
Example: I went to http://www.google.cz and searched for 'How does Google set the HTTP Referrer when someone clicks on a search result link?'. 示例:我访问了http://www.google.cz并搜索了“当有人点击搜索结果链接时,Google如何设置HTTP推荐人?”。 That resulted in this request: 这导致了这个要求:
GET http://www.google.cz/search?hl=cs&source=hp&biw=1276&bih=866&q=How+does+Google+set+the+HTTP+Referrer+when+someone+clicks+on+a+search+result+link%3F&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=b29a84a7dd59af16 HTTP/1.1
Referer: http://www.google.cz/
From there, I clicked the first result link: How does Google set the HTTP Referrer when someone clicks on a search result link? 从那里,我点击了第一个结果链接: 当有人点击搜索结果链接时,Google如何设置HTTP推荐人? That click was captured by a JS event and rerouted to this redirector: 该点击是由JS事件捕获并重新路由到此重定向器:
GET http://www.google.cz/url?sa=t&source=web&cd=1&ved=0CBoQFjAA&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F4402502%2Fhow-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link&rct=j&q=How%20does%20Google%20set%20the%20HTTP%20Referrer%20when%20someone%20clicks%20on%20a%20search%20result%20link%3F&ei=WTgBTeOXLsHB8QPO44ybCA&usg=AFQjCNE22KabWH5TnkK1sRLGmqWQ4EvwxQ HTTP/1.1
Referer: http://www.google.cz/search?hl=cs&source=hp&biw=1276&bih=866&q=How+does+Google+set+the+HTTP+Referrer+when+someone+clicks+on+a+search+result+link%3F&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=b29a84a7dd59af16
containing this redirect snippet: 包含此重定向代码段:
<body><a href="https://stackoverflow.com/questions/4402502/how-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link" id=link target=_parent></body><script>var a=parent,b=parent.google,c=location;if(a!=window&&b){if(b.r){b.r=0;document.getElementById("link").click();}}else{document.getElementById("link").click();};</script><noscript><META http-equiv="refresh" content="0;URL='https://stackoverflow.com/questions/4402502/how-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link'"></noscript>
which finally sent me to the real URL: 最后发送给我的真实网址:
GET https://stackoverflow.com/questions/4402502/how-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link HTTP/1.1
Referer: http://www.google.cz/url?sa=t&source=web&cd=1&ved=0CBoQFjAA&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F4402502%2Fhow-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link&rct=j&q=How%20does%20Google%20set%20the%20HTTP%20Referrer%20when%20someone%20clicks%20on%20a%20search%20result%20link%3F&ei=WTgBTeOXLsHB8QPO44ybCA&usg=AFQjCNE22KabWH5TnkK1sRLGmqWQ4EvwxQ
So, you're correct - most of the heavy lifting here is done through JavaScript, although some server-side code is also involved. 所以,你是对的 - 这里的大部分繁重工作都是通过JavaScript完成的,尽管还涉及一些服务器端代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.