获取iframe的内容高度
const iframe = document.getElementById('iframeId');
iframe.onload =function(){
try{
const doc = iframe.contentDocument||iframe.contentWindow.document;
const body = doc.body;
const html = doc.documentElemet;
const height = Math.max(
body.scrollHeight ,
body.offsetHeight,
html.scrollHeight,
html.offsetHeight
) ;
iframe.style.height=height+'px';
}.catch(e){
console.log('无法获取iframe内容高度',e)
}
}

浙公网安备 33010602011771号