Dynamically change the IFrame height

Source: Internet
Author: User

[Html] dynamically changes the height of the IFrame to achieve automatic IFrame stretching. The parent page is also automatically scaled down. Principle: When the IFrame subpage is loaded, the parent IFrame object is called, change its height: 1. Add JavaScript <script> function IFrameResize () {// alert(this.doc ument. body. scrollHeight); // The height var obj = parent.doc ument of the current page is displayed. getElementById ("childFrame"); // get the IFrame object of the parent page // alert (obj. height); // The height obj set in IFrame in the parent page is displayed. height = this.doc ument. body. scrollHeight; // adjust the IFrame height on the parent page to the height of this page} </script> 2. in the body of the IFrame page (that is, the Child page, add an onload event <body onload = "IFrameResize ()"> 3. Add an ID for the IFrame tag of the parent page, that is, the first step above, childFrame <IFRAME border = 0 marginWidth = 0 frameSpacing = 0 marginHeight = 0 src = "frame1.jsp" frameBorder = 0 noResize scrolling = "no" width = 2nd height = 100% vspale = "0" id = "childFrame"> </IFRAME>

Related Article

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.