首頁  >  文章  >  web前端  >  深入解析contentWindow, contentDocument_基礎知識

深入解析contentWindow, contentDocument_基礎知識

WBOY
WBOY原創
2016-05-16 17:30:111887瀏覽

生活永遠是一個大染缸,一塊白布下去,黑佈出來,一塊黑布下去,一塊七色佈出來。
contentWindow 相容於各個瀏覽器,可取得子視窗的 window 物件。
contentDocument Firefox 支持,> ie8 的ie支持。可取得子視窗的 document 物件。
在子級iframe設定 父級 iframe ,或 孫級 iframe 高度。

複製程式碼 程式碼如下:

function showp. parentWin = parent.document.getElementById("test");
    if(!parentWin) return false;
    var sub = parentWin.contentWindow.document.getElementById("test2"); ) return false;
    var thirdHeight = sub.contentWindow.document.body.offsetHeight; //第三層body 物件
    sub.height = thirdHeight; = x.contentWindow.document.body.offsetHeight; //第二層body 物件
    x.height = secondHeight; //設定第一層iframe 的高度
    //alert(secondHeight);
   /alert('body: ' x.contentDocument.body.offsetHeight ' div:' thirdHeight);
}



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn