最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to resolve issue "Blocked a frame with origin from accessing a frame with origin" in parent.d

programmeradmin2浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 2

What 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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论