手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >深入解析contentWindow, contentDocument
深入解析contentWindow, contentDocument
摘要:生活永远是一个大染缸,一块白布下去,黑布出来,一块黑布下去,一块七色布出来。contentWindow兼容各个浏览器,可取得子窗口的wind...

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

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);

}

【深入解析contentWindow, contentDocument】相关文章:

图片完美缩放

多种js图片预加载实现方式分享

探索angularjs+requirejs全面实现按需加载的套路

巧妙破除网页右键禁用的十大绝招

用javascript动态注释掉HTML代码

javascript消除window.close()的提示窗口

JavaScript实现Iterator模式实例分析

html代码调试脚本

Bootstrap基础学习

kindeditor编辑器点中图片滚动条往上顶的bug

精品推荐
分类导航