document.referrer的问题

use*_*458 5 javascript referrer

我在某些网站上使用document.referrer时遇到了一些麻烦,甚至是使用HTTP协议的参考站点.

  1. 在什么情况下document.referrer可能为空(HTTPS到HTTP除外)?

  2. 获取url引用的最佳方法是document.referrer?

  3. 在我的网站中,document.referrer是空的,但是当我查看Google Analytics网站时,会出现参考文献.

Val*_*jon 7

document.referrer是not empty,如果你的网站的网址是从其他网站点击,像谷歌搜索,从Facebook,微博等..

所以,如果有人打开从书签网站O直接连接类型的网站的网址,document.referrer是empty.

让我们看看这些例子:

点击此链接http://www.w3schools.com/jsref/prop_doc_referrer.asp你可以看到document.referrer是http://stackoverflow.com/questions/28646433/problems-with-document-referrer

如果您在谷歌搜索HTML DOM referrer Property,document.referrer将是http://google.es/...

如果您复制http://www.w3schools.com/jsref/prop_doc_referrer.asp在浏览器中打开新选项卡并粘贴它,document.referrer将会empty.

  • 那么,`CTRL + F5`和`F5`只刷新当前文档内容,而不是HTTP元数据,如标题,cookie等...以下是完整的解释[http://stackoverflow.com/a/385384/3710490 ](http://stackoverflow.com/a/385384/3710490) (2认同)