Is there a way to have content from an IFRAME overflow onto the parent frame? Is there a way to have content from an IFRAME overflow onto the parent frame? javascript javascript

Is there a way to have content from an IFRAME overflow onto the parent frame?


No it's not possible. Ignoring any historical reasons, nowadays it would be considered a security vulnerability -- eg. many sites put untrusted content into iframes (the iframe source being a different origin so cannot modify the parent frame, per the same origin policy).

If such untrusted content had a mechanism to place content outside of the bounds of the iframe it could (for example) place an "identical" login div (or whatever) over a parent frame's real login fields, and could thus steal username/password information. Which would suck.


I couldn't find a way to make the content of the frame flow out of the frame, but I did find a way to hack around it, by moving the tooltip into the parent document and placing it above (z-index) the iframe.

The approach was:
1) find the iframe in the parent document
2) remove the tooltip element from where it is in the DOM, and add it to the parent document inside the element that contains your iframe.
3) you probably need to adjust the z-index and positioning, depending on how you were doing that in the first place.

You can access the parent document of an iframe using parent.document.

jQuery(tooltip).remove();var iframeParent = jQuery("#the_id_of_the_iframe", parent.document)[0].parentNode;iframeParent.appendChild(tooltip);//adjust z-index, positioning


This may be off the mark either because it's unsuitable in light of your requirements, or it may not actually help (!), but it might be worth checking out UFrame. It's a kind of hybrid of iframe and div, and could probably be packaged up as a widget (your best bet would be to give clients a <script> tag which would suck in UFrame and the relevant markup). What I'm not sure about is whether you can achieve the overlay you require, but it's possibly worth a play around with. Sorry I can't be more specific but it's not something I've actually used myself, I just bookmarked it a while back for future reference.