简体   繁体   English

当有人点击搜索结果链接时,Google如何设置HTTP Referrer?

[英]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.

相关问题 搜索结果点击后谷歌如何设置HTTP Referrer - How does Google sets HTTP Referrer after a search result click 当有人点击特定链接时如何显示加载对话框? - How to display loading dialog when someone clicks a specific link? 用户点击链接时如何设置倒数? - How to set a countdown when user clicks on a link? 当有人单击链接(图像)时,是否可以缩放? - Is it possible to zoom, when someone clicks on a link (image)? 单击链接时是否有手动设置自定义 url 为 http header 引荐来源网址 - Is there anyway to manually set custom url for http header referrer when the link is clicked 如何获得谷歌搜索结果的间接链接 - how to get indirect link of google search result 当有人单击特定链接时,如何停止或暂停我使用的脚本之一? - How can I stop or pause one of the scripts I use when someone clicks on a specific link? 当有人重新加载页面或单击链接时,如何捕获 JavaScript 事件? - How can I capture the JavaScript events when someone reloads the page or clicks on a link? 当有人单击打开的链接时,控制文本区域 - control the text area when someone clicks on a link it opens 当有人单击Facebook赞按钮时如何触发事件? (在Google跟踪代码管理器中) - How to trigger an event when someone clicks the Facebook Like Button? (in Google Tag Manager)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM