生活永远是一个大染缸,一块白布下去,黑布出来,一块黑布下去,一块七色布出来。
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);
}