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

    经典代码 iFrame 自适应高度,在IE6/IE7/IE8/Firefox/Opera/Chrome/Safari通过测试。

    var ifm= document.getElementById("user_iframe");
        var subWeb = document.frames ? document.frames["user_iframe"].document : ifm.contentDocument;
        
        if(ifm != null && subWeb != null) {
           ifm.height = subWeb.body.scrollHeight;
        }

    两个iframe嵌套的

    var ifm= document.getElementById("user_iframe");
        var subWeb = document.frames ? document.frames["user_iframe"].document : ifm.contentDocument;
        
        if(ifm != null && subWeb != null) {
           ifm.height = subWeb.body.scrollHeight;
        }
        
        //得到父iframe
        var ifmParent= window.parent.document.getElementById("main_iframe");
        var subWebParent = window.parent.document.frames ? window.parent.document.frames["main_iframe"].document : ifmParent.contentDocument;
        if(ifmParent != null && subWebParent != null){
            ifmParent.height = subWeb.body.scrollHeight;
        }

  • 相关阅读:
    php
    图片拖拽
    12.20
    正则详细讲解
    12.19
    正则
    闭包
    date类
    二分查找
    冒泡排序
  • 原文地址:https://www.cnblogs.com/dingchenghong/p/2526441.html
Copyright © 2011-2022 走看看