Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iframe auto resize that works in Safari as well as IE/FF/Chrome

Status
Not open for further replies.

westbrookmajor

Programmer
Jan 4, 2010
2
US
This code works in all browsers, and the javascript part of this is located as you see it. It does NOT go into the <head> section of your document.

<iframe src="foo/index.html" scrolling="auto" id="frame" width="100%" marginheight="0" marginwidth="0" frameborder="0">
<p>Your browser does not support iframes.</p>
</iframe>
<script type="text/javascript">
function resizeIframe() {
var height = document.documentElement.clientHeight;
height -= document.getElementById('frame').offsetTop;

height -= 0;

document.getElementById('frame').style.height = height +"px";

};
document.getElementById('frame').onload = resizeIframe;
window.onresize = resizeIframe;
</script>
 
Well I was wondering if this actually works in some older versions of Safari and FF. The version of IE I tested this in was 6 and not sure if it works in 7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top