父页面: <iframe src="" frameborder="0" style="width:100%; " id="Iframe"></iframe>
document.getElementById('Iframe').src=子页面地址?参数='' ; //设置iframe的高度,使其自适应 function setIframeHeight(id){ var iframe = document.getElementById(id); iframe.height=0; try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.min(bHeight, dHeight); iframe.height = height+30; }catch (ex){} }
子页面:
function setHeight(){ parent.window.setIframeHeight("Iframe");//调用父页面中改变 iframe标签高度的方法 }