tags:

views:

201

answers:

1
+1  Q: 

iframe sizing

I am displaying pages from an external site (that I own) in an iframe in one of my pages, and it's fine except when viewed in Opera with the browser reduced down (not widescreen), when the iframe shrinks and squashes the content. It works in widescreen (maximise browser window), and is OK in IE7, Firefox, Chrome and Safari in maximise and reduced. I have set the frame dimensions in the HTML and have nested thee iframe in a 'div' whhich is larger than the iframe via the css. Is this a peculiar bug to Opera or is there something I can do about it?

+1  A: 

We had a similar issue with iFrame sizing on our web app main page, although in IE6. The solution was to trap the window.onresize event and call a JavaScript funtion to appropriately size the iFrame. "content" is the name of the iframe we want sized. Also note that we are using ASP.Net AJAX's $get which translates to document.getElementById()

    <script type="text/javascript">
            window.onresize=resizeContentFrame;
            resizeContentFrame();

function resizeContentFrame(){
    setFrameHeight($get('content'));
}

function setFrameHeight(f){
    if(isDefined(f)){
        var h=document.documentElement.scrollHeight;
        h-=(HEADER_HEIGHT+CONTENT_PADDING+5);
        f.style.height=h+'px';
    }
}

        </script>
rams