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 7684665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:04:48+00:00 2026-05-31T19:04:48+00:00

Okay, here goes. Stack Overflow virgin here but hopefully you guys will be able

  • 0

Okay, here goes. Stack Overflow virgin here but hopefully you guys will be able to help me.

I have been playing around with resizing the height of an iframe based on it’s content. The content varies as a user will progress through a series of forms, this means that each submit will result in a new form of which there are 3 forms.

The code below is called when the iframe loads,

function checkHeight() {
    var frame=document.getElementById('frame');
    var doc=frame.contentWindow.document;
    var data=doc.getElementById('data');
    alert(data);
    var data_height=data.offsetHeight;
    if(data_height) {
        frame.style.height=data_height + 'px';
        alert('height has been set');
    }
}

This is working fine on both mac and pc versions of Mozilla, IE and Safari but I am having a massive issue with chrome. It is not returning a document within the frame. Is this a permissions error or what?!

I have also tried contentDocument but to no avail.

All the documents reside on my server and are all within the same folder.

Thanks in advance.

  • 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-05-31T19:04:50+00:00Added an answer on May 31, 2026 at 7:04 pm

    Edit:

    I’ve re-read your question – would it be simpler to just calculate the height inside the iframe’s document and call the parent resizing function since they are in the same security sandbox (i.e. on the same domain)?

    Original:

    Since a somewhat similar thing happens when the iframes are embedded from a different domain (cannot access iframe..document) I’d speculate this approach would work:

    1. First: calculate the document height in the document itself (i.e. inside the iframe).
    2. Pass the values to the parent using window.postMessage/hash polling for older browsers. There is a neat library that takes care of compatibility for you.
    3. Receive the value in the parent and resize the iframe accordingly.

    Again, this may be overkill, but given that the solution has been tested to do exactly what you’re after between different security sandboxes, this should also be the case for a simpler scenario if iframes are on the same domain.

    That being said, if they are on the same domain (as opposed to widgets/non-mashable third party content) is there really need for an iframe? Sounds like it’s just a matter of setting up jQuery to make ajax requests and populate container(s) with new data.

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

Sidebar

Related Questions

Okay guys hopefully I can explain this effectively, so here goes. I have a
Okay, this is going to be hard to explain but here goes nothing: Lately
Okay I might be entirely off track now but here goes: Our webshop offers
Okay, so this is a long long shot but here it goes... When IE
Okay I hate to ask this question ... but here goes. I am writing
Okay, this is a bit abstract, but here goes: I'm creating a website and
Okay here's the program I have typed up(stdio.h is included also): /* function main
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay here is what I'm trying to do: I have a model object that
Okay basically here's where I'm at. I have a list of PropertyDescriptor objects. These

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.