導讀 跟大家講解下有關深入解析contentWindow, contentDocument_基礎知識,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說深入解
跟大家講解下有關深入解析contentWindow, contentDocument_基礎知識,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說深入解析contentWindow, contentDocument_基礎知識,小編也收集到了有關深入解析contentWindow, contentDocument_基礎知識的相關資料,希望大家看到了會喜歡。
生活永遠是一個大染缸,一塊白布下去,黑布出來,一塊黑布下去,一塊七色布出來。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);}來源:php中文網