/*
* 设置iframe高度自适应
*/
function reinitIframe(){
var myframe = document.getElementById('myFrame');
var bHeight = myframe.contentWindow.document.body.scrollHeight;
var dHeight = myframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
myframe.height = height;
}
window.setInterval("reinitIframe()", 200)
iframe也要有一个默认的高度
<iframe src="medicalRecord.html" frameborder="0" name="myFrame" id="myFrame" scrolling="no" onload="this.height=100"></iframe>
网友评论