iframe框架调用高度自适应技巧
发布时间:2021-12-07 11:59:35 所属栏目:PHP教程 来源:互联网
导读:01 iframe frameborder=0 src=http://www.daixiao360.cn/ class=iframe frameborder=0 id=test onload=this.height=100 width=762px scrolling=no/iframe 02 script type=text/javascript 03 function reinitIframe(){ 04 var iframe = document.getElementBy
01 <iframe frameborder="0" src="http://www.daixiao360.cn/" class="iframe" frameborder="0" id="test" onload="this.height=100" width="762px" scrolling="no"></iframe> 02 <script type="text/javascript"> 03 function reinitIframe(){ 04 var iframe = document.getElementById("test"); 05 try{ 06 var bHeight = iframe.contentWindow.document.body.scrollHeight; 07 var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; 08 var height = Math.max(bHeight, dHeight); 09 iframe.height = height; 10 console.log(height); 11 }catch (ex){} 12 } 13 window.setInterval("reinitIframe()", 200); 14 </script> ![]() (编辑:青岛站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
热点阅读