深入解析contentWindow, contentDocument |
生活永远是一个大染缸,一块白布下去,黑布出来,一块黑布下去,一块七色布出来 。 复制代码 代码如下: 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); } |