`); iframeDoc.close(); iframeDoc.body.style.margin = '0'; // 设置iframe高度 var setIframeTimer = null; var templateBoxHeight = 0; var previousHeight = 0; function setIframeHeight(loaded) { if (setIframeTimer) clearTimeout(setIframeTimer); // 获取iframe内文档的高度 var height = iframeDoc.documentElement.scrollHeight || iframeDoc.body.scrollHeight; if (!templateBoxHeight) { var htmlTemplateBox = document.getElementById('htmlTemplateBox'); templateBoxHeight = htmlTemplateBox.clientHeight; } // 设置iframe高度 if ((height > 0 && height > templateBoxHeight && height == previousHeight) || loaded) { if (loaded) height = height + 12; iframe.style.height = height + 'px'; } else { previousHeight = height; } if (!loaded) { setIframeTimer = setTimeout(setIframeHeight, 60); } } setIframeHeight(); window.onload = function() { setIframeHeight(1); }; }
Top
Support
ATest