如果您使用location.href =重定向到新网页,是否设置了REFERER?

| 如果使用javascript
location.href = <url>
将用户重定向到新网页,目标Web服务器会看到什么REFERER标头?     
已邀请:
它会看到它来自的页面,就像单击链接一样。 要从任何页面进行测试,请重定向到phpinfo()页面或任何其他回显标头的页面,例如:
window.location=\'http://hosting.iptcom.net/phpinfo.php\';
(从随机Google搜索中拉出的页面)     
除某些例外,发送的标头是带有重定向的页面的标题,而不是执行重定向的页面的引荐来源。这与保留原始引荐来源网址的服务器端重定向相反。 因此,如果访问者从
A.html
转到
B.html
,并且
B.html
触发了
location.href
重定向到
C.html
,则Web服务器会将
B.html
视为引荐来源。 (如果在服务器端从
B.html
重定向到
C.html
,则
A.html
将成为
C.html
的引荐来源。) 较旧版本的Internet Explorer将发送空白标头,因为(一如既往)从HTTPS重定向到HTTP。     
大多数浏览器将传递带有location.href的HTTP_REFFERER,但在某些情况下IE不会。 如果中继员对您真的很重要,那么您可以这样做:
function goTo(url) {
 var a = document.createElement(\"a\");
 if(!a.click) { //Only IE has .click so if it doesnt exist use the simple method where the refferer is passed on other browsers.
  location.href = url;
  return;
 }
 a.setAttribute(\"href\", url);
 a.style.display = \"none\";
 (document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(a);
 a.click();
}
    

要回复问题请先登录注册