Javascript for 100% height Iframe

Posted by northernavenger on Dec 1, 2009 in tech | Subscribe

I found a lot of sites giving incorrect code to do this so here is some java that worked for me.

<div id=”sitecontainer”>

<iframe id=”frame” src=”http://feeds.feedburner.com/Multimedia-GoogleNews?format=xml” width=”100%” frameborder=”0″ marginheight=”0″ marginwidth=”0″></iframe>
<script type=”text/javascript”>
function resizeIframe() {
var height = document.documentElement.clientHeight;
height -= document.getElementById(’frame’).offsetTop;

// not sure how to get this dynamically
height -= 20; /* whatever you set your body bottom margin/padding to be */

document.getElementById(’frame’).style.height = height +”px”;

};
document.getElementById(’frame’).onload = resizeIframe;
window.onresize = resizeIframe;
</script>

</div>

VN:F [1.3.2_665]
Rating: 0.0/10 (0 votes cast)

Tags: ,

Leave a Reply

XHTML: You can use these tags:' <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2010 Da Room All rights reserved.
Shades v1.3.2 theme from BuyNowShop.com.