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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:40:12+00:00 2026-05-11T00:40:12+00:00

I am working on an iGoogle-like application. Content from other applications (on other domains)

  • 0

I am working on an iGoogle-like application. Content from other applications (on other domains) is shown using iframes.

How do I resize the iframes to fit the height of the iframes’ content?

I’ve tried to decipher the javascript Google uses but it’s obfuscated, and searching the web has been fruitless so far.

Update: Please note that content is loaded from other domains, so the same-origin policy applies.

  • 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-11T00:40:12+00:00Added an answer on May 11, 2026 at 12:40 am

    We had this type of problem, but slightly in reverse to your situation – we were providing the iframed content to sites on other domains, so the same origin policy was also an issue. After many hours spent trawling google, we eventually found a (somewhat..) workable solution, which you may be able to adapt to your needs.

    There is a way around the same origin policy, but it requires changes on both the iframed content and the framing page, so if you haven’t the ability to request changes on both sides, this method won’t be very useful to you, i’m afraid.

    There’s a browser quirk which allows us to skirt the same origin policy – javascript can communicate either with pages on its own domain, or with pages it has iframed, but never pages in which it is framed, e.g. if you have:

     www.foo.com/home.html, which iframes  |-> www.bar.net/framed.html, which iframes      |-> www.foo.com/helper.html 

    then home.html can communicate with framed.html (iframed) and helper.html (same domain).

     Communication options for each page:  +-------------------------+-----------+-------------+-------------+  |                         | home.html | framed.html | helper.html |  +-------------------------+-----------+-------------+-------------+  | www.foo.com/home.html   |    N/A    |     YES     |     YES     |  | www.bar.net/framed.html |    NO     |     N/A     |     YES     |  | www.foo.com/helper.html |    YES    |     YES     |     N/A     |  +-------------------------+-----------+-------------+-------------+ 

    framed.html can send messages to helper.html (iframed) but not home.html (child can’t communicate cross-domain with parent).

    The key here is that helper.html can receive messages from framed.html, and can also communicate with home.html.

    So essentially, when framed.html loads, it works out its own height, tells helper.html, which passes the message on to home.html, which can then resize the iframe in which framed.html sits.

    The simplest way we found to pass messages from framed.html to helper.html was through a URL argument. To do this, framed.html has an iframe with src='' specified. When its onload fires, it evaluates its own height, and sets the src of the iframe at this point to helper.html?height=N

    There’s an explanation here of how facebook handle it, which may be slightly clearer than mine above!


    Code

    In www.foo.com/home.html, the following javascript code is required (this can be loaded from a .js file on any domain, incidentally..):

    <script>   // Resize iframe to full height   function resizeIframe(height)   {     // '+60' is a general rule of thumb to allow for differences in     // IE & and FF height reporting, can be adjusted as required..     document.getElementById('frame_name_here').height = parseInt(height)+60;   } </script> <iframe id='frame_name_here' src='http://www.bar.net/framed.html'></iframe> 

    In www.bar.net/framed.html:

    <body onload='iframeResizePipe()'> <iframe id='helpframe' src='' height='0' width='0' frameborder='0'></iframe>  <script type='text/javascript'>   function iframeResizePipe()   {      // What's the page height?      var height = document.body.scrollHeight;       // Going to 'pipe' the data to the parent through the helpframe..      var pipe = document.getElementById('helpframe');       // Cachebuster a precaution here to stop browser caching interfering      pipe.src = 'http://www.foo.com/helper.html?height='+height+'&cacheb='+Math.random();    } </script> 

    Contents of www.foo.com/helper.html:

    <html>  <!--  This page is on the same domain as the parent, so can communicate with it to order the iframe window resizing to fit the content  -->    <body onload='parentIframeResize()'>      <script>        // Tell the parent iframe what height the iframe needs to be       function parentIframeResize()       {          var height = getParam('height');          // This works as our parent's parent is on our domain..          parent.parent.resizeIframe(height);       }        // Helper function, parse param from request string       function getParam( name )       {         name = name.replace(/[\[]/,'\\\[').replace(/[\]]/,'\\\]');         var regexS = '[\\?&]'+name+'=([^&#]*)';         var regex = new RegExp( regexS );         var results = regex.exec( window.location.href );         if( results == null )           return '';         else           return results[1];       }     </script>    </body>  </html> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
Working on a small game using an HTML5 canvas, and javascript. And it's working
Working on game where plates will be falling from top to bottom. Some plates
Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how
I'm building a dummy widget for a iGoogle/Netvibes like portal. This is a Google
Working on a Windows 8 (metro style) application, and want to reference a service
working on using a formula ive been using for a while to find distances
Working on an app using Akka 2 deployed with Play-mini. I pulled logback into
Working on calling a C function from my asm project. I'm trying to push
I've been working on a gadget that will run in iGoogle. In fact, it's

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.