FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Variable length of iFrame





jasperlevink
Hello folks!

I use for my site an iframe (I know itsn't an ideal solution).
Can the height of the iframe be variable according to its content?

Grtz.
Jasper
Acela
try using height in percentages if that doesnt work than their is only changing it by pixels which wont change with content but i think framesets can change with content im not sure about that
jasperlevink
Wouldn't it be possible to get the height of a div within the content of an iframe and apply it to the height of the iframe. With JS for example?
Acela
it could be why dont u search google for javascript codes pertaining to that im not good with javascript
Panthrowzay
A solution to that that I found while starting out is simply frames with idenically content that changes with the page added with a "meta tag" fading tequicnice makes it infallable over high speed connections. if your making a site in Frontpage and you are skilled with Frontpage iFrames are not difficul, but be careful of liking offsite material it looks horible. also try using them with out borders.
Naif
I couldnt really get the reason why you would want to do that? Do you want to avoid the vertical scrollbars from showing up? Have a look at my personal website, I have used an iframe. Used a javascript I downloaded from somewhere for scrolling. What you are trying to do should very well be possible using Javascript. Like Acela has asked you, use mighty google to search for "how".
supjapscrapper
jasperlevink wrote:
Hello folks!

I use for my site an iframe (I know itsn't an ideal solution).
Can the height of the iframe be variable according to its content?

Grtz.
Jasper


I remember that Heights of frames could not be controlled since they operate by space division. that means if you say I divide my page in two sides one frame on the link side, you can say how wide you want it to be, but not how high since it is gonna directly fill in all space available from its division.
if now you divide hirizontally and not vertically, its is gonna be symetric, since the frame is gonna be able to have its height set but not its width, which is even if you set it, the browser won't take care of the parameter in this context.
I hope I've been clear and simple.
have a nice day Very Happy
jasperlevink
Thanks for your reactions!

I've found the following solution:

Code:

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

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

function resize_iframe(){
document.getElementById("sizeframe").height=100 // 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>

<iframe width=300 id="sizeframe" name="sizeframe" src="" scrolling="no" frameborder="yes" onload=resize_iframe()></iframe>



And it seems to work rather well!
Grtz.
Related topics
Flash MX
E-Cards with PHP & MySQL
PB PHP, Iframe and Javascript
Clock-javascript
Tutorial: Image Rollovers w/ Javascript
Save webpage source into javascript variable
Bluetooth
[JS?] variable length of iframe
AJAX tutorial [2nd part now updated]
C/C++
PHP Chat (now rather good) how to design socket chat?
what does this javascript do
Javascript Hypertext Transreceiver and Processor (JS HTP)
World Database
Reply to topic    Frihost Forum Index -> Webmaster and Internet -> Design Tips

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.