Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an iframe take vertical space

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?

like image 250
Beriadan Avatar asked Aug 29 '08 16:08

Beriadan


People also ask

How do I make my iframe full size?

To size the <iframe> , we ignore the width="560" height="315" element properties, and instead use the CSS properties width:100%;height:100%; . That's it: a full-width <iframe> with fixed aspect ratio. Enjoy.


1 Answers

This should set the IFRAME height to its content's height:

<script type="text/javascript">
the_height = document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
document.getElementById('the_iframe').height = the_height;
</script>

You may want to add scrolling="no" to your IFRAME to turn off the scrollbars.

edit: Oops, forgot to declare the_height.

like image 199
ceejayoz Avatar answered Sep 24 '22 16:09

ceejayoz