iframe自适应高度
iframe自适应高度,实现原理是在iframe页面加载完成后将页面的高度赋值到iframe上。
非原创,来自于博客园的留言。
<iframe id="myIframe" src="/src.html" style="width:1220px; border:0px;" scrolling="no" onload="autoHeight()"></iframe>
function autoHeight() {
var ifr = document.getElementById('myIframe'); ifr.height = (ifr.contentDocument && ifr.contentDocument.body.offsetHeight) || (ifr.contentWindow.document.body.scrollHeight);}

浙公网安备 33010602011771号