生活永遠(yuǎn)是一個(gè)大染缸,一塊白布下去,黑布出來(lái),一塊黑布下去,一塊七色布出來(lái)。
contentWindow 兼容各個(gè)瀏覽器,可取得子窗口的 window 對(duì)象。
contentDocument Firefox 支持,> ie8 的ie支持??扇〉米哟翱诘?document 對(duì)象。
在子級(jí)iframe設(shè)置 父級(jí) iframe ,或 孫級(jí) iframe 高度。
復(fù)制代碼 代碼如下:
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 對(duì)象
sub.height = thirdHeight; //設(shè)置第二層 iframe 的高度
var secondHeight = x.contentWindow.document.body.offsetHeight; //第二層 body 對(duì)象
x.height = secondHeight; //設(shè)置第一層 iframe 的高度
//alert(secondHeight);
//alert('body: ' + x.contentDocument.body.offsetHeight + ' div:' + thirdHeight);
}
新聞熱點(diǎn)
疑難解答
圖片精選