iframe自适应高和宽代码实现


rt,以下为iframe自适应高宽实现关键代码

///控制代码
<
script type="text/javascript"> function reinitIframe(){ var iframe = document.getElementById("iframe1"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.height = height; }catch (ex){} } window.setInterval("reinitIframe()", 200); </script>
 ///iframe标签

<iframe src="/Product/ifPro.aspx" id="iframe1" frameborder="0" scrolling="no" width="100%" onload="this.height=100"></iframe>

  

以上文章由本人收集整理进行撰写,版权归属博客园及本人。欢迎转载和引用,但必须在转载和引用的开头或来源标注博客名称和该篇文章的链接地址。
原文地址:https://www.cnblogs.com/whitehouse/p/2679045.html