Forum Moderators: open

Message Too Old, No Replies

iFrame is not auto resized in responsive design

         

toplisek

10:34 pm on Dec 5, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have tested iframe solution like:
jQuery(document).ready(function()
{
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
obj.style.width = obj.contentWindow.document.body.scrollWidth + 'px';
}
}
);

and
<iframe sandbox='allow-scripts allow-same-origin' onload='javascript:resizeIframe(this); src='myfile.php'></iframe>

When I see tested page it will not resize. How to solve this auto height/width in the case of iframes?

Need help.

Hoople

9:10 pm on Dec 6, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



iFrames are a special beast like Framesets and Rules. Sometimes styling them works and sometimes with other browsers it doesn't work totally, or as in your case not at all.

Have you thought of using SSI aka Server Side Includes to inject the remote document?

Hoople

7:38 am on Dec 8, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This seems like a LOT of extra work: http://responsivenews.co.uk/post/71845174511/responsive-iframes [responsivenews.co.uk]
but it's from an authoritative source.

lucy24

9:03 am on Dec 8, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you thought of using SSI aka Server Side Includes to inject the remote document?

But can you use an SSI with material from a different domain? The one advantage of an iframe is that you can put absolutely anything inside it.

<iframe sandbox='allow-scripts allow-same-origin' onload='javascript:resizeIframe(this); src='myfile.php'></iframe>

That kinda looks as if it is all your own content. If so, an SSI might really be a better way to go. How many different pages have the iframe?