Translations of this page?:

Resize IFrames according to their contents

If you want to have IFrames integrated with the iframe plugin to have a height matching their content you can paste the following into a lib/plugin/iframe/script.js:

Note this only works with content served from the same server.

function resizeIframe(currentfr){
    if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight){
        //ns6 syntax
        currentfr.height = 50+currentfr.contentDocument.body.offsetHeight;
        currentfr.style.height = (50 + currentfr.contentDocument.body.offsetHeight) + 'px';
    } else if (currentfr.document && currentfr.contentWindow.document.body.scrollHeight){
        //ie5+ syntax
        currentfr.height = 50+currentfr.contentWindow.document.body.scrollHeight;
        currentfr.style.height = (50 + currentfr.contentWindow.document.body.scrollHeight)+'px';
    }
    currentfr.style.display = 'block';
}
 
addInitEvent(function(){
    var frames = document.getElementsByTagName('iframe');
    for(var i=0; i<frames.length; i++){
        var currentfr = frames[0];
        addEvent(currentfr,'load',function(){resizeIframe(currentfr);});
        resizeIframe(currentfr);
    }
});
tips/resizeiframes.txt · Last modified: 2008/12/02 12:35 by andi
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate