I often see sites using iframes containing an external site, and a top frame containing JavaScript functionality for the user.
e.g. user analytics software, Digg bar, etc...
Any tips for experimenting on something similar? =) Would be awesome to know
Adding CSS File to iFrameYou can add entire CSS file instead of injecting separated styles by creating link and add it to the iframe's head. This method does not work with cross domain content. You'll need to set appropriate CORS header but it's not recommended due to security risks.
You can not change the styles of the page that resides within the iframe.
You can not directly apply styles to the inner IFrame element through parent window CSS class even though its domain is same as parent. As ,(All the iframe's domain is the same as the parent) .. Best thing you can do is ,to add your main style sheet to the IFrame using javascript or jquery.
Yes you can, with javascript. Note it works best with the iframe URL and the parent URL sharing the same domain.
No, not from outside the iframe. An <iframe>
is its own world. If the domains etc. match, then Javascript can communicate in and out, and could (if it wanted to) inject CSS into a child frame.
If the <iframe>
contains content from a different domain, there's pretty much nothing you can do. The parent page controls the size of the frame and whether it's visible, and can put its own content over the frame by positioning etc, but it can't directly effect the way the actual frame content is rendered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With