1

Topic: Need updated resize Java script code or Iframe

Hello everyone,

I really hope someone can lend me a helping hand in regards to my issue.  I followed the Step by Step How to embed a forum into your Vld Script directions and everything seems to work great, except for one thing.  When I view the Punbb forum in Firefox, it doesn't automatically resize the height.  It works perfect in Internet Explorer!  So I'm not sure if the code needs to be updated or maybe I'm just doing something wrong but any help would be appreciated.  I added the codes below so you can take a look.

THIS IS THE IFRAME CODE THAT I USED:

<iframe width="100%" id="iframe_id" name="iframe_name" src="http://www.mysite.com/forum/" scrolling="no" frameborder="0" ALLOWTRANSPARENCY="true" onload=resize_iframe();></iframe>


THIS IS THE RESIZE JAVA SCRIPT THAT I USED:

<script type="text/javascript">
<!--

moz=document.getElementById&&!document.all
mozHeightOffset=20

function resize_iframe(){
document.getElementById("iframe_id").height="" // required for Moz bug, value can be "", null, or integer
document.getElementById('iframe_id').height=window.frames["iframe_name"].document.body.scrollHeight+(moz?mozHeightOffset:0)
}

// -->
</script>


Thanks

2

Re: Need updated resize Java script code or Iframe

I have a similar issue when trying to embed a different site. Resizing doesn't work 100% of the time, so you may just want to turn on scrolling to see if it would solve the issue.

3

Re: Need updated resize Java script code or Iframe

Hi everyone!

Sorry to wake up an old thread.

I wonder if you ever found a solution to this problem?

The auto resize works fine in all browsers except Firefox...

4

Re: Need updated resize Java script code or Iframe

I finally got it to work!

Use this code in the head:

<script type="text/javascript">

/* iFrame SSI IV - iframe auto-resize height script
 * ©2008 John Davenport Scheuer
 * This notice must remain for legal use. */

function sizeFrame(){
if(document.getElementsByTagName('frameset').length||!document.getElementsByTagName('iframe').length)
return;
var frEls=document.getElementsByTagName('iframe'), s='scrollHeight',
frObs=window.frames, o='offsetHeight', b='body', de='documentElement';
for (var cs, hb, hd, d='document', i = frEls.length-1; i > -1; --i){
if(frObs[i][d][b].style.overflow)
cs=frObs[i][d][b].style.overflow;
frObs[i][d][b].style.overflow='hidden';
frEls[i].height=10;
frEls[i].height=Math.max(frObs[i][d][b][o], Math.max(frObs[i][d][de][o],
(hd=frObs[i][d][de][s]) != (hb=frObs[i][d][b][s])? Math.max(hd, hb):0))+
(frEls[i].height==frEls[i].offsetHeight&&frEls[i].getAttribute('frameborder',0)!=='0'?4:0);
frObs[i][d][b].style.overflow=typeof cs=='string'? cs : '';
};
if(!sizeFrame.setup){
for (var i = frEls.length-1; i > -1; --i)
sizeFrame.loadup(frEls[i]);
sizeFrame.setup=true;
}};

sizeFrame.loadup=function(o){
if ( typeof window.addEventListener != "undefined" )
o.addEventListener( "load", sizeFrame, false );
else if ( typeof window.attachEvent != "undefined" )
o.attachEvent( "onload", sizeFrame );
else {
if ( o.onload != null ) {
var oldOnload = o.onload;
o.onload = function(e) {
oldOnload(e);
sizeFrame();
};
}
else
o.onload = sizeFrame;
}};

if(document.getElementsByTagName&&window.frames)
sizeFrame.loadup(window);

</script>

And this in the body:

<iframe src="/forum/index.php" width="100%" scrolling="no" frameborder="0"></iframe>