假设我的网页位于http://www.website.com,其中包含 <iframe>
. 像这样:
<html>
<head>...</head>
<body>
...
<iframe src="http://www.washington.edu">
...
</body>
</html>
现在假设某人访问www.website.com并点击iframe本身的链接(此链接位于www.washington.edu网站上) .
我的问题是在这种情况下什么是HTTP Referer?
是http://www.website.com(托管iframe的页面)还是http://www.washington.edu(点击链接的页面)?
2 回答
这取决于浏览器 .
Firefox和Safari会将引荐来源报告为http://www.website.com,而某些版本的Internet Explorer将显示http://www.washington.edu作为引荐来源 .
更新2015-04:测试上述最新版本,所有这些都将返回http://www.washington.edu
当前的浏览器
截至2015年8月,在这种情况下,所有主流浏览器(Safari,Chrome,Firefox)都应将
Referer
HTTP标头设置为http://www.washington.edu .但是,如果您的应用程序严重依赖于
Referer
值,我建议您测试特定浏览器版本在特定情况下的行为方式 .我这样写是因为例如我发现Safari 8当前为iframe中加载的JavaScript提出了错误的
Referer
请求,可能是因为之前已经使用不同的Referer
请求了这个JavaScript . 这是一个类似于this particular one的错误,仅在2014年在Chromium关闭 . (我已经向Apple报告过,顺便说一下 . )旧浏览器
历史上Internet Explorer 6 showed different behaviour than described above - 它会将
Referer
HTTP标头设置为http://www.website.com .