Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 152935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:42:43+00:00 2026-05-11T09:42:43+00:00

I can see that this question has been asked several times, but none of

  • 0

I can see that this question has been asked several times, but none of the proposed solutions seem to work for the site I am building, so I am reopening the thread. I am attempting to size an iframe based on the height of it’s content. Both the page that contains the iframe and it’s source page exist on the same domain.

I have tried the proposed solutions in each of the following threads:

  • Resize iframe height according to content height in it
  • Resizing an iframe based on content

I believe that the solutions above are not working because of when the reference to body.clientHeight is made, the browser has not actually determined the height of the document.

Here is the code I am using:

    var ifmBlue = document.getElementById('ifmBlue');     ifmBlue.onload = resizeIframe;      function resizeIframe()     {         var ifmBlue = document.getElementById('ifmBluePill');         var ifmDiv = ifmBlue.contentDocument.getElementById('main');         var height = ifmDiv.clientHeight;         ifmBlue.style.height = (ifmBlue.contentDocument.body.scrollHeight || ifmBlue.contentDocument.body.offsetHeight || ifmBlue.contentDocument.body.parentNode.clientHeight || height ||  500) + 5 + 'px';     } 

If I debug the script using fire debug, the client height of the iframe.contentDocument’s main div is 0. Additionally, body.offsetHieght, & body.scrollHeight are 0. However, after the script is finished running, if I inspect the DOM of the HTML iframe element (using fire debug) I can see that the body’s clientHeight is 456 and the inner div’s clientHeight is 742. This leads me to believe that these values are not yet set when iframe.onload is fired. So, per one of the threads above, I moved the code into the body.onload event handler of the iframe’s source page. This solution also did not work.

Any help you can provide is much appreciated.

Thanks,

CJ

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:42:44+00:00Added an answer on May 11, 2026 at 9:42 am

    DynamicDrive has such a script, which I think does what you’re asking for.

    There’s also a newer version now.


    2011 update:

    I would strongly recommend using AJAX over something like this, especially considering that a dynamically resizing iframe only works across the same domain.

    Even so, it’s a bit iffy, so if you absolutely must use AJAX over standard page loading, you really, really should use things like history.pushState (and have standard page loading as a fallback for browsers that don’t support it). There’s a jQuery plugin which handles this stuff for you, written by a GitHubber, called pjax, which they use only for repo navigation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Works for me, GNU/Linux with gij 4.3.2. Make sure all… May 11, 2026 at 11:21 am
  • added an answer You can use the -c or --command=<command> option to execute… May 11, 2026 at 11:21 am
  • added an answer Check the introduction in this: http://jibbering.com/faq/faq_notes/closures.html. It can help you… May 11, 2026 at 11:21 am

Related Questions

I created the setup project for the application and I can see that the
I can see in the postgresql logs that certain simple queries (no joins and
How do I set environment variables from Java? I see that I can do
I see that EF can update a model based on an existing database schema.
I know that I can make a setter that checks to see if a
I see in the MATLAB help ( matlab -h ) that I can use
While googling, I see that using java.io.File#length() can be slow. FileChannel has a size()
I have an Interface called IStep that can do some computation (See Execution in
I can see people asking all the time whether multiple inheritance should be included
I can see line numbers in my error logs in our development environment, in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.