Iframe中的滚动条在内容之前结束。那么有没有办法将滚动条高度设置为内容的高度

时间:2017-10-27 12:30:44

标签: javascript css iframe scrollbar

所以,有人可以帮助我,有一个大的网页,当滚动条结束时,大约70%的网页被削减

代码:

</div>
    <div id="divCustomDataPreview" title="Custom Form Preview"   style="background-color: #ffffff; height:580px; !important; display: none;overflow:hidden; " >
        <iframe  id='ifrCustomDataPreview' style="border: 0px; overflow:hidden !important;" scrolling="yes" width='100%' height='100%' onload='javascript:resizeIframe(this);'></iframe>
    </div>
    <div id="divFormCreate" title="Convert To Form" style="display: none;background-color:#FFFFFF">


function resizeIframe(obj) {
    var BrowserName=BrowserDetecting().split('#')[0];
    if(BrowserName == "Chrome" || BrowserName == "Safari")
        obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
    else                
        obj.style.height=obj.contentWindow.document.documentElement.scrollHeight + 'px';
}

1 个答案:

答案 0 :(得分:0)

我使用js函数来设置高度并且它起作用。但我的问题是settimer在iframe加载之前设置了高度:

function resizeIframe(iframeID) {   
    var iframe = window.parent.document.getElementById(iframeID);
    var container = document.getElementById('content');

    iframe.style.height = container.offsetHeight + 'px';            
}