IFRAME Auto Height

That’s not what I get: http://www.facebust.me/test.html
However if you want to restore the www in cases where it doesn’t get specified, you could try running this code in the <head> of your parent page:

<script type="text/javascript">

(function( subDomain )
{
  var href = location.href,
      locn;  
    
  if( href.indexOf( 'http' ) == 0 && !href.match( ":\\/{2,}" + subDomain + "\\." ) )
  { 
    locn = href.split( /:\\/{2,}/ );   
    
    location.href = locn[ 0 ] + "://" + subDomain + "." + locn[ 1 ];
  }  
    
})( 'www' );

</script>

It is, simply compressed using the website jscompressor.com. Anyways, I added that script you recommended and it works now! Thank you! By the way: can you please change the URL in your post to the tinyurl, http://tinyurl.com/7fkq8oq, that way it won’t show up in Google :)? Thanks again!

One thing that is weird, is that on the test page it works fine in FF, but when I implement it on my live site, it doesn’t work anymore - it simply sets the height to 0. It does work great in Safari & in Chrome. Any suggestions?

Try this version, otherwise show your URL.

<script type='text/javascript'>

function setIframeHeight( iframeId ) /** IMPORTANT: All framed documents *must* have a DOCTYPE applied **/
{
  var ifDoc, ifRef = document.getElementById( iframeId ), tempW, tempH;

  try
  {   
    ifDoc = ifRef.contentWindow.document.documentElement;  
  }
  catch( e )
  { 
    try
    { 
      ifDoc = ifRef.contentDocument.documentElement;  
    }
    catch(ee)
    {   
    }  
  }
 
  if( ifDoc )
  {
    tempH = ifDoc.scrollHeight;   
    ifRef.height = 1;  
    ifRef.height = tempH;
  
    /* For width resize, enable below.  */
  
    //tempW = ifDoc.scrollWidth;
    //ifRef.width = 1;
    //ifRef.width = tempW; 
 }
}

</script>

Sadly this didn’t work either, shoot! Really appreciate your help…

Although this is possible I would call the method a bit of a “hack” and wouldn’t really reccomend it.

AJAX would be a much better solution

Would you care to outline the algorithm you would apply?

My approach would depend on what exactly I am trying to do.

What are you using the iFrame for?

Apparently it’s wrapping a forum of his. When people visit different pages of his forum, he wants the iframe to change height depending on the content on the page inside of the iframe.

See my approach to this would be to not have the forum in the iFrame anyway!

Are you doing this because you want a consistent design on your website and forum. If so I’d highly recommend getting your forum templated. Having a forum in an iframe seems like a terrible idea. Firstly you wont be able to link to threads, but there are many other reasons

I just realised you said in the OP that it was a forum, Totally missed this when I first read it

I am trying to utilise the code that you provided to CB Resources In October 2010

but as yet haven’t been able to work out exactly how I use it.

That is because of course because I am very new to JavaScript design.

Can I just ask for a little bit of assistance in setting it up correctly

thank you