获取包含片段标识符的引荐网址 [英] Get Referrer URL including fragment identifier

查看:94
本文介绍了获取包含片段标识符的引荐网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在另一个网站中嵌入了一个名为 iframe 的网站,它们来自不同的域。

我需要在地址栏中获取url,包括iframe中的散列符号(#)之后的部分。使用 document.referrer 我可以得到所有的东西,直到散列,有没有办法做到这一点?

解决方案

给定标准的 RFC2616 (章节14.36)片段标识符不包含在引用者标题中。 JavaScript W3C定义规定了一个参考到 RFC2396 中指定的完整URI,其中包含片段标识符。



尽管我没有看到任何技术原因,但浏览器实现无法在JavaScript中提供完整的引用,我认为实现非常接近HTTP规范,甚至可能依赖于浏览器。据我所知,所有浏览器都使用JavaScript来实现引用链接,而不使用片段标识符。


I have a website embedded as iframe in another website, they are from different domains.

I need to get the url in the address bar including the part after hash sign (#) from the iframe. With document.referrer I can get everything until the hash, is there a way to do this?

解决方案

Given the standard RFC2616 (chapter 14.36) the fragment identifier is not included in the referrer header. The JavaScript W3C definition states a reference to a full URI as specified in RFC2396 which would include the fragment identifier.

While I see no technical reason a browser implementation could not give a full referrer in JavaScript I suppose the implementation is very close to the HTTP specs and maybe even browser dependent. To my knowledge all browsers implement the referrer in JavaScript without fragment identifier.

这篇关于获取包含片段标识符的引荐网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆