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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745254924a4618899.html
评论列表(0条)