zoukankan      html  css  js  c++  java
  • 关于 contentWindow, contentDocument

    没有永恒的技术只有变态的需求,没有好说的客户只有无奈的开发者,

    如果iframe的出现是一个错误的话,iframe里边在来一个iframe那是错上加错,神话没有在远古的尘嚣中消失,却在怀具的今天不断上演。

    生活永远是一个大染缸,一块白布下去,黑布出来,一块黑布下去,一块七色布出来。

    contentWindow 兼容各个浏览器,可取得子窗口的 window 对象。

    contentDocument Firefox 支持,> ie8 的ie支持。可取得子窗口的 document 对象。

    在子级iframe设置 父级 iframe ,或 孙级 iframe 高度。
     
    function showIframeH(){
        
    var parentWin = parent.document.getElementById("test");
        
    if(!parentWin) return false;
        
        
    var sub = parentWin.contentWindow.document.getElementById("test2");
        
    if(!sub) return false;
        
        
    var thirdHeight = sub.contentWindow.document.body.offsetHeight; //第三层 body 对象
        
        sub.height 
    = thirdHeight; //设置第二层 iframe 的高度
        
        
    var secondHeight = x.contentWindow.document.body.offsetHeight; //第二层 body 对象
        x.height = secondHeight; //设置第一层 iframe 的高度
        //alert(secondHeight);
        //alert('body: ' + x.contentDocument.body.offsetHeight + ' div:' + thirdHeight);
    }
     
  • 相关阅读:
    Asp.Net MVC4 系列--进阶篇之路由 (2)
    Asp.Net MVC4 系列-- 进阶篇之路由(1)
    ASP.NET MVC AJAX的调用示例
    MVC中Controller控制器相关技术
    MVC中View界面数据呈现示例
    IEnumerable,ICollection,IList,List之间的区别
    Dapper数据库相关操作
    集合类---Map
    工厂模式
    适配器模式与外观模式
  • 原文地址:https://www.cnblogs.com/chris-oil/p/3362402.html
Copyright © 2011-2022 走看看