<iframe id="iframe" src="xxxx.html" scrolling="no" width="100%"></iframe>
function reinitIframe(iframId) {
var iframe = document.getElementById(iframId);
console.log(iframe)
try {
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
// console.log(iframe.contentWindow);
// console.log(bHeight, dHeight);
} catch (ex) {}
};
setTimeout(function() {
reinitIframe(iframeId)
}, 500);
如果没效果,可适当加大 timeout 的时间