获取包含片段标识符的引荐网址

编程入门 行业动态 更新时间:2024-10-23 01:30:23
本文介绍了获取包含片段标识符的引荐网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在另一个网站中嵌入了一个名为 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.

更多推荐

获取包含片段标识符的引荐网址

本文发布于:2023-10-12 23:28:53,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标识符   片段   网址

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!