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

I have popup fancybox iframe opens on clicking a button in my site, I have two urls to access the site

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745254924a4618899.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信