zoukankan      html  css  js  c++  java
  • iframe高度自适应

    方法一:

    <iframe src="http://www.fulibac.com" id="myiframe" scrolling="no" onload="changeFrameHeight()" frameborder="0"></iframe>

    js代码也得跟着改

    function changeFrameHeight(){
        var ifm= document.getElementById("iframepage"); 
        ifm.height=document.documentElement.clientHeight;

    }

    window.onresize=function(){  
         changeFrameHeight();  

    window.onresize的作用就是当窗口大小改变的时候会触发这个事件。

    方法二:

    <iframe src="需要连接的iframe地址" id="iframepage" name="iframepage" frameBorder=0 scrolling=no width="100%" onLoad="iFrameHeight()" ></iframe>
    js代码:
    <script type="text/javascript" language="javascript">
    function iFrameHeight() {
    var ifm= document.getElementById("iframepage");
    var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
    if(ifm != null && subWeb != null) {
    ifm.height = subWeb.body.scrollHeight;
    }
    }
    </script>
  • 相关阅读:
    DataGridView
    View Designer
    错题集
    MetalKit_1
    倍道而行:选择排序
    ARKit_3_任意门
    ARKit__2_尺子项目
    关于scrollview的无限滚动效果实现
    tableview折叠动效
    NSURLSession的简单使用
  • 原文地址:https://www.cnblogs.com/ch-zaizai/p/5962754.html
Copyright © 2011-2022 走看看