Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iFrame resize

Status
Not open for further replies.

pahiker

Programmer
Aug 31, 2012
45
US
I know this topic has been done a lot, but what I have tried does not seem to work well, at least in my situation.

Here is my development site: Link

What should happen is that the left side (Father's Prayer) should resize to fit the content. The content is located in different pages, all on my site. Currently, I am just working with the "Contact Us" button until it works. If you click on it the iFrame does resize, but that is because my script sets a fixed size (the script is inside the ContactUs.html page):


<script>
window.onload = parent.document.getElementById("Content").height = 800;
</script>

But, this requires me to determine the ideal size of each child page loaded, I'd rather not do that. Is there a way to have the js determine the size of the page that it is in? Many of these pages will include images, so I need to know the "after loaded" size.

Thanks in advance.
 
Okay, I've made some progress. I found how to update the iFrame size, and to get a general height of the child's body, but not an exact size:

<script>
function loaded() {
var s = document.body.clientHeight;
parent.document.getElementById('Content').height = s + 100;
}
</script>

On the site this is the "About Us" page and, as you see, I had to adjust the size by 100. The "Contact Us" page is similar, but with and adjustment of 50. Is there any way to get closer to an exact height so that either I have a constant adjustment, or I get the exact size I need?

Let all bear in mind that a society is judged not so much by the standards attained by its more affluent and privileged members as by the quality of life which it is able to assure for its weakest members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top