Posted on: 11/27/04 04:16pm
By: Nezz
Well I think I have a workaround for the cross-browser compatibility issues with dynamic IFRAME resizing and the Static Pages plugin.
<head>
<script language="JavaScript">
function resize() {
var iframe = document.all.NAME;
iframe.height=document.frames("NAME").document.body.scrollHeight;
}
</script>
</head>
<body onload=resize();>
<iframe src="URL" name="NAME" scrolling="no" width="100%" height=100% frameborder="0" onload="this.height=this.contentDocument.height"></iframe>
</body>
Just replace the src=URL and the NAME wiith your own data and paste it into the Static Page block and it seems to work fine in both IE and Firefox and Opera (newest builds, IE complains a little about this.height but so what...). I have not tested it in other browsers yet but I'm happy with the resutls so far... So if you don't need to support old,old browsers this will make you a happy camper.
Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 03/17/05 01:04pm
By: Anonymous (kranthi)
I tried your code , but its giving error while running scripts like
" Access is denied , Do you want to continue running scripts" and not resizing the height.
Do you have any idea about what the problem might be and have any solution for that?
Thank you very much
kranthi.
Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 07/12/06 09:44pm
By: Anonymous (josh kotecha)
Is it possible to do this with ID instead of name tag?
Also, is it possible to retrive the name tag of a frame
once you have the frame id ?
The reason why I ask is I have older code that does this with
iframe id. It doesn't work with opera. I'd like to leave the
main html page the same and make changes in the javascript
function to resize the way you are doing the resize.
Thanks!!!
Josh
p.s.
Nice job figuring this out ...
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 01/25/07 12:46am
By: Anonymous (visitor)
this line of syntax is wrong. might work in IE but not FF
Text Formatted Code
iframe.height=document.frames("NAME").document.body.scrollHeight;
here is the correct syntax
Text Formatted Code
iframe.height=window.frames["NAME"].document.body.scrollHeight;
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 03/06/08 03:49am
By: Anonymous (mp)
Thank you so much! ive been struggling to do this for days now.
Found loads of other tutorials how to do it with both JS and AJAX, tho none of em worked on a php generated webpage.
(a specified category of a forum, page doesn't really exist)
This one DOES work! YAY :banana:
A scrollbar does appear when its not needed tho im not really irritated by it, ill just play around with it to see if i can fix that, if not, its good like this.
(think mite have somthin to do with the margin i set up, but ill look into that later today.
Tnx again!
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 07/08/08 02:41pm
By: Anonymous (Eugene)
Hi the code works great in FF, I haven't been able to make it work in IE yet the way I'm using it,
My links are in a FLASH file.
I have on index file, with 2 iframes in it, with a flash header at the top and the other pages in the bottom iframe.
Any advice for the code to work in the flash??
here is the action script 1.0 I'm currently using:
on (press) {
getURL("gallerij.html", "main"
;
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 08/11/08 09:22pm
By: Anonymous (swmasson)
Hi there,
been looking for something like this for ages... and finally one that works... well nearly... if a link is used within the iframe then the iframe will not resize to the new content... the iframe height remains the same...
does anyone know how to fix this?
Thanks
Regards
SWM
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 01/04/09 04:00pm
By: Anonymous (Barnz)
THANK YOU
SOOOO MUCH!
I've been googling for
DAYS to find a solution to this. Thank you so much
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 05/10/09 05:46pm
By: Anonymous (Anupam)
THIS CODE DOESN'T WORK IN GOOGLE CROME, NETSCAPE 9 !!!!
DIDN'T CHECKED IN FIREFOX.
PLZ CHECK
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 06/10/09 09:38pm
By: Anonymous (Dade)
damn yo this works great in safari 4 and it was easy!
THANK YOU
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 06/24/09 03:05pm
By: Anonymous (Bret)
looks like what i have been looking for... 1 issue it doesnt seem to make the iframe smaller when you reload to a shorter content -- at least not in opera, if this is what it is im fine with that but if there is a fix awesome... i wasnt able to make the code work as the OP made it
Text Formatted Code
<html>
<head>
<script language="JavaScript">
function resize() {
var iframe = document.all.F1;
iframe.height=window.frames("F1").document.body.scrollHeight;
}
</script>
</head>
<body>
<center>
a bunch of other stuff
<iframe name="F1" src ="frame1.php?cat=0" scrolling="no" width="630" height=100% frameborder="0" onload="resize()"</iframe>
</body>
</html>
he had a
Text Formatted Code
<body onload="resize();>
that did not work for me... could this be where the shorting problem is comming from?
do i put that onload into the parent body or the iframe body?
thanks for your help
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 09/30/09 02:33pm
By: Anonymous (Baggins)
It doesn't work in Firefox.... did somebody fix it???
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 11/23/09 06:29am
By: Anonymous (bob)
hello everbody,
I've found this script (here -> "http://forum.jswelt.de/javascript/31676-iframe-dynamisch-h-he-anpassen.html"
to change the iframe height dynamically.
it only works correctly in IE8 (other IE-browser not tested), other brother tested: mozFirefox, googleChrome and safari.
does anybody have an idea, how to make it work for the other browser?
function resizeMe(n, id) {
d=0;
ifObj=document.getElementsByName(n)[0];
p=(document.all)?'scroll':'offset';
eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body'
[0]."+p+"Height+"+d);
}
the iframe looks like that:
<iframe id="MContenIFrame" name="main" onload="javascript:parent.resizeMe('MContenIFrame'
;" src="start.html"> </iframe>
I'm searching for days, but still hasn't found any working solution for any browser other than IE8...
..thank you for any help!
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 11/23/09 06:34am
By: Anonymous (bob)
sry for the smileys...it's my first entry in a forum!
the code again without (..hopefully)
Text Formatted Code
function resizeMe(n, id) {
d=0;
ifObj=document.getElementsByName(n)[0];
p=(document.all)?'scroll':'offset';
eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d+31);
}
Text Formatted Code
<iframe id="MContenIFrame" name="main" onload="javascript:parent.resizeMe('MContenIFrame');" src="start.html"> </iframe>
best regards
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 06/16/11 05:35am
By: Anonymous (Guru)
useless and hope less code
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 07/11/11 12:19pm
By: Anonymous (Hendy)
this is the solution i've been looking for, nice, good, and work for my problem...thanks.. :banana:
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 08/20/11 03:47pm
By: Anonymous (ken)
i ran that version without problems in firefox up to version 5 and ie
__________________________________________________________
<head>
<script language="JavaScript">
function resize() {
var iframe = document.all.NAME;
iframe.height=document.frames("NAME"
.document.body.scrollHeight;
}
</script>
</head>
<body onload=resize();>
<iframe src="URL" name="NAME" scrolling="no" width="100%" height=100% frameborder="0" onload="this.height=this.contentDocument.height"></iframe>
</body>
__________________________________________________________
now with new firefox 6 this doesn t function:
[21:42:51.597] document.all is undefined
can anyone help?
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 08/21/11 10:38am
By: suprsidr
My solution:
Text Formatted Code
<script type="text/javascript">
function autoIframe(frameId, moreSpace){
try {
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
frame.style.height = innerDoc.body.scrollHeight + moreSpace +"px";
document.getElementsByTagName("title")[0].innerHTML = innerDoc.getElementsByTagName("title")[0].innerHTML;
}
catch (err) {
window.status = err.message;
}
}
</script>
<iframe id="gallery_frame" src="/gallery2/embed_samples/inset.php" frameborder="0" width="100%" scrolling="auto" style="height:400px;" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('gallery_frame',20);}">Your browser does not support inline frames</iframe>
@see it working
here[*1] .
-s
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 11/09/11 05:40pm
By: Anonymous (Ryan)
even though your site works in Chrome for me I cannot get the code to work in Chrome.
You code works in Safari however. Any ideas?
Re: Dynamic IFRAME resizing cross browser issues in Static Pages
Posted on: 11/10/11 05:06pm
By: suprsidr
you would have to provide url to offending page.