我在另一个网站中嵌入了一个名为 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.
更多推荐
获取包含片段标识符的引荐网址
发布评论