admin管理员组文章数量:1416642
I have popup fancybox iframe opens on clicking a button in my site, I have two urls to access the site
1. www.xyz
2. xyz
On clicking on a button a pop up will appear, In that page i am getting the parent page URL as follows
parent.document.title
which works fine in first URL(www.xyz)
, But in second URL(xyz)
, it throws a JavaScript error as follows
Uncaught SecurityError: Blocked a frame with origin "www.xyz" from accessing a frame with origin "xyz". Protocols, domains, and ports must match.
Basically, I want to retrieve the parent page title, How to do this using jquery/javascript
I have popup fancybox iframe opens on clicking a button in my site, I have two urls to access the site
1. www.xyz.
2. xyz.
On clicking on a button a pop up will appear, In that page i am getting the parent page URL as follows
parent.document.title
which works fine in first URL(www.xyz.)
, But in second URL(xyz.)
, it throws a JavaScript error as follows
Uncaught SecurityError: Blocked a frame with origin "www.xyz." from accessing a frame with origin "xyz.". Protocols, domains, and ports must match.
Basically, I want to retrieve the parent page title, How to do this using jquery/javascript
Share Improve this question asked Feb 26, 2014 at 12:27 n92n92 7,60228 gold badges97 silver badges131 bronze badges1 Answer
Reset to default 2What you have to do is make sure the iframe isn't loading from the other domain name. If you've written the HTML for the iframe, it would need to change from something like this:
<iframe src="http://www.xyz./iframe/page.html"></iframe>
To something like this:
<iframe src="/iframe/page.html"></iframe>
Doing it that way makes sure the URL requested will always be from the current domain name, and it should work as intended. It's the same idea if you're using a plugin that grabs the URL from a link. Take off the domain so it loads from the current one.
本文标签:
版权声明:本文标题:javascript - How to resolve issue "Blocked a frame with origin from accessing a frame with origin" in parent.d 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745254924a2650044.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论