1

Hi I have a question about iframes and crossdomains. The answers I found left me just confused. Some say it's possible, others say it's not possible. So I hope that someone here will give me the answer I've been looking for. so my question goes like this:

for example I have the website: www.apple.com and I load an iframe with a new url: www.banana.com. In www.banana.com I have 2 comboboxes, When I change the value of the first, the second would be changed. But when I change the value I get a permission denied.

I don't have to copy the value to www.apple.com, so it stays in www.banana.com. What did work was when I opened the frame in a new tab. So my question is: is it a cross domain issue and is there a way to let the comboboxes work?

I work with this line in www.banana.com :

if (window.parent.vulin){ var docPrefix = window.parent.vulin; }else{ var docPrefix = window.parent; } 

and it's the parent.vulin that has the permission problem.

7
  • Do you control the content on both domains? Commented Mar 1, 2012 at 15:53
  • no, but I do know the person who does control the content of the 1st site, and I control the content of the 2nd site. (so the site in the iframe) Commented Mar 2, 2012 at 7:19
  • Take a look at this: nczonline.net/blog/2010/05/25/… Commented Mar 2, 2012 at 7:29
  • So This change has to be made on siteA(appel) and not siteB(banana)? Commented Mar 2, 2012 at 7:56
  • Yes, the window doing the scripting needs slight changes to the javascript code for IE, and the server of the target window needs to send the Access-Control-Allow-Origin HTTP header. Commented Mar 2, 2012 at 8:07

1 Answer 1

1

Since you have some amount of control over both domains, you can get around the cross-domain policy using "Cross-Origin Resource Sharing," or CORS.

http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/

The technique involves having the server of the target window send the Access-Control-Allow-Origin HTTP header, and modifying the JavaScript code in the other window slightly to appease IE.

Sign up to request clarification or add additional context in comments.

1 Comment

I was just thinking, isn't there a way to just change this part of the code to change the "window.parent" to something different. Because now window.parent.location will give appel.com instead of banana.com. So that's probebly why the div can't access window.parent. ? (just a thought)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.