I would like to have an iframe
take as much vertical space as it needs to display its content and not display a scrollbar. Is it at all possible ?
Are there any workarounds?
I would like to have an iframe
take as much vertical space as it needs to display its content and not display a scrollbar. Is it at all possible ?
Are there any workarounds?
Adding a
DOCTYPE
declaration to theIFRAME
source document will help to calculate the correct value from the linesee W3C DOCTYPE for examples
I was having problems with both IE and FF as it was rendering the
iframe
document in 'quirks' mode, until I added theDOCTYPE
.FF/IE/Chrome support: The .scrollHeight doesnt work with Chrome so I have come up with a javascript example using jQuery to set all
IFRAME
heights on a page based on the iframes content. NOTE: This is for reference pages within the your current domain.Also check out this thread: How does the DiggBar dynamically resize its iframe's height based on content not on their domain?.
It addresses the same question.
This should set the
IFRAME
height to its content's height:You may want to add
scrolling="no"
to yourIFRAME
to turn off the scrollbars.edit: Oops, forgot to declare
the_height
.This CSS snippet should remove the vertical scrollbar:
I'm not sure yet about having it take up as much vertical space as it needs, but I'll see if I can't figure it out.
The workaround is not to use
<iframe>
and preprocess code on server-side.