iframe sizing - cross browser issue

…衆ロ難τιáo~ 提交于 2019-12-10 10:32:25

问题


I am displaying pages from an external site (that I own) in an iframe in one of my pages. It's all fine except when viewed in Opera with the browser window size reduced (not widescreen), when the iframe shrinks and squashes the content. It works in widescreen (maximize browser window), and is OK in IE7, Firefox, Chrome and Safari in maximize and reduced window size. I have set the frame dimensions in the HTML and have nested the iframe in a div which 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:


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 function 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()

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';
    }
}


来源:https://stackoverflow.com/questions/91721/iframe-sizing-cross-browser-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!