简体   繁体   English

跨域时如何获取parent.document.referrer?

[英]How get the parent.document.referrer when cross domain?

Here is my problem: 这是我的问题:

  1. page A in domain X 域X中的页面A
  2. page B in domain Y 域Y中的B页
  3. A have a iframe,and link to B A有一个iframe,并链接到B

Now i can get the A's location in B by document.referrer,but my boss give me a new task: 现在我可以通过document.referrer获取A在B中的位置,但是我的老板给了我一个新任务:

get the A's referer 得到A的推荐人

First i tried:parent.document.referrer,it is as expected i encountered this error:"unsafe ... in cross domain". 首先我尝试了:parent.document.referrer,这是我遇到的错误:“跨域不安全...”。

So,guys,it's possible to get A'referer?How can i do it? 所以,有可能得到“推荐人”吗?我该怎么办?

Thanks! 谢谢!

This is not possible. 这是不可能的。 You can only access the REFERER of the page that is reaching you. 您只能访问与您REFERER的页面的“ REFERER人”。 You can read more about that here . 您可以在此处阅读更多有关此内容的信息

You could bypass it though by providing the referer through a querystring variable. 您可以通过提供查询字符串变量的引用来绕过它。

Eg 例如

<iframe src="http://www.domainy.com?ref=Myreferer"></iframe>

Note though that a REFERER is not always set. 请注意,尽管并非始终设置REFERER Usually (but it varies in the different browsers) it is set when the page is reached by clicking a link, but there will be none when a user navigates directly to your webpage (enters URL in address bar) or by selecting one of his favorites. 通常(但在不同的浏览器中会有所不同),它是通过单击链接到达页面时设置的,但是当用户直接导航到您的网页(在地址栏中输入URL)或选择他的收藏夹之一时就没有设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM