<iframe id="stageFrame" src="/home/index" style="width:100%;min-height:600px;"></iframe>
//根据iframe里面的内容高度动态设置iframe高度
var ifr = document.getElementById('stageFrame');
ifr.onload = function () {
ifr.style.height = '700px';
var iDoc = ifr.contentDocument || ifr.contentWindow.document;
//document.body.scrollHeight
//var height = iDoc.documentElement.clientHeight || iDoc.body.clientHeight;
var height = iDoc.body.scrollHeight + 100;
//console.log(iDoc.documentElement.clientHeight, iDoc.body.clientHeight);
ifr.style.height = height + 'px';
console.log(height);
}
根据iframe里面的内容高度动态设置iframe高度
最新推荐文章于 2023-12-29 12:51:09 发布