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

  • SEARCH
  • Home
  • 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 8519227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:11:29+00:00 2026-06-11T06:11:29+00:00

I have a problem in my javascript which is just to resize an iFrame

  • 0

I have a problem in my javascript which is just to resize an iFrame based on the content. I have it working in other places but for this one example it is throwing an error. Using the following code the body is null and therefore can’t get scrollHeight.

if(document.getElementById('iFrameHelpDesk') != null)
{
    var Height = document.getElementById('iFrameHelpDesk').contentWindow.document.body.scrollHeight;

    document.getElementById('iFrameHelpDesk').height = Height + 40;
}

The html used is:

<iframe src="http://<snipped webaddress>" id="iFrameHelpDesk" scrolling="no" frameborder="no"></iframe>

Why does this not populate the body object?

  • 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. Editorial Team
    Editorial Team
    2026-06-11T06:11:31+00:00Added an answer on June 11, 2026 at 6:11 am

    Fairly simply I took the code from the document load ($(function() {})) method and put it into it’s own method for when the actual iframe loads. Ie.

    $('#iFrameHelpDesk').load(function() {
    
        var Height = document.getElementById('iFrameHelpDesk').contentWindow.document.body.scrollHeight;
    
        document.getElementById(iFrameHelpDesk').height = Height + 40;
    
    });
    

    This works perfectly, as it should. But it’s now confused me as to why some other iframes, which I perform similar code on, are working fine from within the document load. But this works and I’m happy enough with that.

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

Sidebar

Related Questions

I have a very simple JavaScript/jquery code which won't just work correctly. The problem
I have this javascript which is working great - var employeename = $(#employeename); var
So I have a rather basic javascript problem which I have been slamming my
I have a very strange problem in which identical pieces of Javascript are behaving
I have one problem with Javascript Nodes.I want to find out what button was
I have a problem with JavaScript magic. When I execute this code: var page
I have a problem with a javascript set of functions that I made. This
I have a very simple Javascript (jQuery) code, which just add a class name
I have a problem when converting a static html table to one which is
I have problem with javascript code. I am using google maps and I am

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.