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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:41:58+00:00 2026-05-28T04:41:58+00:00

http://jsfiddle.net/fJkBU/1/ That’s my code. Basically, I have an iFrame whose source may change. I

  • 0

http://jsfiddle.net/fJkBU/1/

That’s my code. Basically, I have an iFrame whose source may change. I need the containing DIV to expand vertically to accomodate whatever is inside the iFrame.

I can’t get it to work. Any ideas?

MY CODE

<!DOCTYPE html>
<html>
  <head>
    <title>Ruby on Rails: Welcome aboard</title>
  </head>
  <body>
    <div id="page">
      <div id="content">

        <div id='commentLoader' style="width: 500px;">
            <iframe id="commentIframe" src="http://www.amazon.com" style="border-style: none; width: 100%; height: 100%"></iframe>
        </div>
      </div>
    </div>
  </body>
</html>
  • 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-28T04:41:58+00:00Added an answer on May 28, 2026 at 4:41 am

    All the other methods will not work, because…

    …Mozilla (and all other major browsers, as pointed out in paislee’s comment) has this thing called the “Same Origin Policy” which states:

    The same origin policy prevents a document or script loaded from one
    origin from getting or setting properties of a document from another
    origin.

    Essentially, Mozilla makes sure you cannot access another webpage’s properties thru JavaScript because that would be a security hazard (for cookie hijacking and such I believe).


    For example, here was a similar question when discussing an iframe for a page of the same origin; here is the answer as applied to your problem. As you can see in Firefox’s error console, your “permission denied to access property document”…

    Ok, so you have a couple of options now that you know you can’t access the iframe’s height thru JavaScript (because it is hosted on another domain):

    1. Change it so you do control the contents of the iframe (then either put it under the same domain or use the solution posted in the similar question).
    2. Assuming 1 is not possible you have to use your server to access the webpage. The first option here would be to screen scrape the contents of the iFrame and then display it

      • If you aren’t up for writing a screen scraper you could use a proxy script and then display an iframe of your proxy (hosted on the same server); this would permit you to access the site as if it we’re your own and the user would notice no difference (Note: I’m pretty sure this is against all terms of service/possibly illegal as the user could try to interact with the website (unaware it is loaded thru a proxy) in the iframe (i.e. login)… and you would effectively be phishing)
    3. I am assuming that what is loaded in the iframe is a set of comments (IDs kind of gave it away), and I will also take the liberty of assuming each comment has a fixed height or maximum height. In which case you could write a php script that loads the page, counts the amount of comments (regex) and then multiplies number that by comment height to determine the appropriate height of the iframe

    Good luck,

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

Sidebar

Related Questions

I have the following code: http://jsfiddle.net/SPWWx/ I'm completely new to javascript, this is my
I need help concerning following code: http://jsfiddle.net/8PsdE/ <SELECT ID=pizzasize NAME=pizzasize> <OPTION VALUE=s>small <OPTION VALUE=m>medium
http://jsfiddle.net/cwUcM/ I've gone through all of the other threads that seems to have a
http://jsfiddle.net/xysxD/11/ if you check the jsfiddle Will have a comment text that slide toggle
http://jsfiddle.net/B2rdD/3/ I've Created 25 buttons using HTML and I have written jquery code such
http://jsfiddle.net/LUfgY/ It doesn't show it there but if that code is run on normal
http://jsfiddle.net/AndyMP/nUhhf/1/ This is a simplified situation where I have a DIV that animates downwards
I have this script: http://jsfiddle.net/NV2uV/ It works, but I do not like it. Cons:
Even though the following works: http://jsfiddle.net/N7D5r/ My attempt at using the same code does
http://jsfiddle.net/9BCrs/5/ I have this set up to load a file into a DIV using

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.