Forum Moderators: open
For now, i just set a huge value for the height to make sure that the content will always fit (if not, an ugly scrollbar would appear) : <iframe src="http://example.com/gb.cgi?gid=553378&prot=prhnfk" width="100%" height="4000"></iframe>
I tried in vain 100% and other things...
Does anybody know how i could set the height dynamically to fit everything right every time?
Thanks,
JAM
[edited by: tedster at 4:04 am (utc) on April 14, 2003]
[edit reason] remove sig file [/edit]
I don't think you can do it (at least I don't see an easy way). Using a percentage makes it a percentage of what contains it, not a percentage of its contents.
You could try play around with using Javascript to do something like a word count of your contents, then manipulate the height attribute through the DOM.
If you don't want the scrolling, why use an iframe?
Shawn
I think that i need a javascript that would be able to compute the height of the table displayed in an <iframe> and use this dynamic value as the height in the <iframe> tag.
Something like :
<iframe src="page.html width="100%" height="(height of main table in page.html)"></iframe>
I would really appreciate the help of an expert here.
Thanks,
JAM
[edited by: tedster at 3:30 am (utc) on April 14, 2003]
[edit reason] sig file [/edit]
Especially because text is involved here, the height of the containing table isn't determined before it's rendered. Even if the HTML gives the table a height attribute, browers only take that as a "suggestion." Browsers are allowed to overrule the table's height attribute if they need to in order to render all the content. There are many threads here where people struggle with this issue - table width and height attribute can be, and regularly ARE, changed by user agents.
So I can't see how you could get the needed height before the document is rendered, and it isn't rendered before the iframe is set up. It's a catch-22.
What I meant by my previous post was to just render the page, then use the onload() method (which only fires after the document has been rendered) to calculate the required height, and then change it by accessing its height attrib through the DOM.
Shawn