views:

86

answers:

3

Hello

I cant access values inside my iFrame it gives me permission denied. I have access on both pages (parent and child).

I added the following javascript line on both pages:

document.domain = "sub.domain.com";

but firebug gives me : Illegal document.domain value

and when i try to access element inside the iFrame it prompts : Permission denied for http://sub1.domain1.com to call method Location.toString on http://sub2.domain2.com

Thanks

A: 

Cross-Domain Scripting is not allowed. http://en.wikipedia.org/wiki/Cross-site_scripting

Not working:

http://sub1.domain1.com
http://sub2.domain2.com

Working:

http://sub1.domain1.com
http://sub2.domain1.com
Yves M.
Yes i know, I want to set them to the same domain, but the (document.domain = "domain.com") is not working properly.
wael34218
+1  A: 

You can only set document.domain to a superdomain of the pages actual domain, not an entirely different one (https://developer.mozilla.org/en/DOM/document.domain). So if you set up 1.sub.domain.com and 2.sub.domain.com you should be able to set document.domain on both of them to sub.domain.com and that should work.

Abhishek Amit
do you mean that i can change x.example.com to y.exmaple.com but i cant change it to y.example2.com ?
wael34218
Not quite. You can only change x.example.com to example.com. You can basically only strip existing parts off of the domain, not add any new ones. example2.com or sub.domain.com in your setup aren't part of the original domain, so can't be added in.
Abhishek Amit
ah perfect .. it worked thanks
wael34218
A: 

Some hacks for Cross domain communication with iframes ~> http://softwareas.com/cross-domain-communication-with-iframes

letronje
I have went through it before
wael34218