开发者

Styling a parent from a child off-site Iframe?

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?


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.


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

Cross-frame communication proof-of-concept

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜