iframe 无滚动条自动拉伸

<iframe src="需要连接的iframe地址" id="iframepage" name="iframepage" frameBorder=0 scrolling=no width="100%" onLoad="iFrameHeight()" >
</iframe>

js代码:function setIFrameHeight(iframe) {
    var oHeight = 0;
    var sHeight = 0;
    var cHeight = 0;
    if (iframe && !window.opera) {
        if (iframe.contentDocument && iframe.contentDocument.body.offsetHeight) {
            oHeight = iframe.contentDocument.body.offsetHeight;
        }
        if (iframe.Document && iframe.Document.body.scrollHeight) {
            sHeight = iframe.Document.body.scrollHeight;
        }
        if(iframe.contentDocument && iframe.contentDocument.documentElement.scrollHeight){
            cHeight = iframe.contentDocument.documentElement.scrollHeight;
        }
        var lheight = Math.max(oHeight, sHeight);
        var height = Math.max(lheight, cHeight);
        iframe.height = height + 20;
    }
}

你可能感兴趣的:(iframe)