views:

36

answers:

2

This is most likely possible, but I want to style the main page using CSS while all I have access is a sandboxed iframe child. Please note that the child iframe is on a different subdomain than the parent.

Can this be done? and how?

+2  A: 

I don't believe this is possible because the child frame is on a different subdomain. This violates the Same origin policy, and as a result, and Javascript in your frame should not be able to access the parent page, nor will any CSS selectors you apply inside your child frame.

If you're in control of both pages on the different subdomains, you can try setting the document.domain property to your common domain name. This should allow the two pages to access each other via Javascript, which would allow you to invoke methods in the parent page. I've actually tried this in the past unsuccessfully, so I'm not sure where I went wrong. More info about document.domain.

wsanville
A: 

It can be done. The iframe should have access to edit the parent frame's "location.hash".

Cross-frame communication proof-of-concept

Oxyrubber