iframe高度自適應頁面的高度
阿新 • • 發佈:2018-12-10
<div class="tpl-content-wrapper"> <iframe id="frameId" frameborder="0" scrolling="no" height="auto" src="" onLoad="iFrameHeight()"></iframe> </div>
<script type="text/javascript" language="javascript"> function iFrameHeight() { var ifm= document.getElementById("frameId"); var subWeb = document.frames ? document.frames["frameId"].document : ifm.contentDocument; if(ifm != null && subWeb != null) { ifm.height = subWeb.body.scrollHeight; } } </script>