...

View Full Version : Auto fit iframe to content



jitu78
12-05-2006, 09:47 AM
Hi All,

I am working on site where I am using iframes for dynamic html files.
Each html file having own length and my iframe height is fixed.

How can I set auto height for each page coming in iframe?


- Jits
globtier.com (http://www.globtier.com)

Mr J
12-06-2006, 07:09 PM
Give this a try


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

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

function resize_iframe(){
document.getElementById("iframe_id").height=100 // default heightdocument.getElementById('iframe_id').height=window.frames["iframe_name"].document.body.scrollHeight+(moz?mozHeightOffset:0)
}
// -->
</script>

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

jitu78
12-07-2006, 10:43 AM
Give this a try


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

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

function resize_iframe(){
document.getElementById("iframe_id").height=100 // default heightdocument.getElementById('iframe_id').height=window.frames["iframe_name"].document.body.scrollHeight+(moz?mozHeightOffset:0)
}
// -->
</script>

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



I had tried this but not working properly in OPERA browser.

Thanks
- Jits



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum