Life is always a big dye vat. When a piece of white cloth goes out, black cloth comes out. When a piece of black cloth goes out, a piece of seven-color cloth comes out.
contentWindow is compatible with various browsers and can obtain the window object of the child window.
contentDocument Firefox support, > IE8 support. The document object of the child window can be obtained.
Set the parent iframe or grandchild iframe height in the child 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; //Third layer body object
sub.height = thirdHeight; //Set the height of the second layer iframe
var secondHeight = x.contentWindow.document.body.offsetHeight; //Second layer body object
x.height = secondHeight; //Set the height of the first layer iframe
//alert(secondHeight);
/ /alert('body: ' x.contentDocument.body.offsetHeight ' div:' thirdHeight);
}