![](/img/trans.png)
[英]JQuery Get Parent URL in IFrame:iframe and its parent are in Different domain
[英]IFrame get parameters from parent url on different domain
似乎这在默认情况下是不可能的,因为我收到错误阻止了原点为x的帧访问原点为y的帧。 我知道这是出于安全原因,但我想允许合作伙伴集成我的iframe。 iframe位于域mysubdomain.mysite.com上,并包含搜索框。 用户进行搜索后,它已被重定向到页面partners-domain- contains-search-results.com,搜索结果也位于域mysubdomain.mysite.com上,我想从url中读取参数(哈希和查询字符串参数),但是我不能,因为我无法读取父url参数(从partners-domain- contains-search-results.com)。
您应该能够使用subdomain.mysite.com中的top.location
来读取partners- top.location
的父URL:
例如,从托管在mysubdomain.mysite.com上并嵌入在partners-domain- contains-search-results.com中的iframe中?hello = true#blabla,您应该可以运行:
top.location.hash
>"#blabla"
top.location.search
>"?hello=true"
注意:您无法修改其他域的位置对象,否则您将看到:
未捕获的SecurityError:被阻止与原籍“帧http://domain2.com访问的帧与原籍”“ http://domain.com ”。 协议,域和端口必须匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.