Life is always a big dyeing cylinder, a piece of white cloth down, black cloth out, a piece of black cloth down, a piece of colorful cloth out.
ContentWindow is compatible with various browsers and the window objects of subwindows can be obtained.
ContentDocument Firefox support,> ie support for ie8. Obtain the document Object of the subwindow.
Set the parent iframe or sun-level iframe height in the Child iframe.
Copy codeThe Code is as follows:
Function showIframeH (){
Var parentWin = parent.doc ument. getElementById ("test ");
If (! ParentWin) return false;
Var sub = parentwin.contentwindodoc ument. getElementById ("test2 ");
If (! Sub) return false;
Var thirdHeight = sub.contentdomaindoc ument. body. offsetHeight; // The third-layer body object
Sub. height = thirdHeight; // sets the iframe height of the second layer.
Var secondHeight = x.contentdomaindoc ument. body. offsetHeight; // The second-level body object.
X. height = secondHeight; // you can specify the iframe height of the first layer.
// Alert (secondHeight );
// Alert ('body: '+ x. contentDocument. body. offsetHeight + 'div:' + thirdHeight );
}