目录
ftl文件js文件ftl文件
// A code block<div class="layui-tab-content"><div class="layui-tab-item layui-show "><iframe width=100% id="myiframe" onload="setHeight()" height="1" scrolling="no"frameborder="0" src=""></iframe></div></div>
js文件
在js
中写入
function getIframeWindow(obj) {return obj.contentWindow || obj.contentDocument.parentWindow;}function getIframeHeight(obj){var idoc = getIframeWindow(obj).document;if(idoc.body){return Math.max(idoc.body.scrollHeight,idoc.body.offsetHeight);}else if(idoc.documentElement){return Math.max(idoc.documentElement.scrollHeight,idoc.documentElement.offsetHeight);}}function setHeight(){var myiframe = document.getElementById("myiframe");myiframe.height = getIframeHeight(myiframe);}