In-depth analysis of contentWindow and contentDocument

Source: Internet
Author: User

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 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.