Skip to content

Instantly share code, notes, and snippets.

@edm00se
Last active August 29, 2015 14:03
Show Gist options
  • Save edm00se/7e462a206baf670e367c to your computer and use it in GitHub Desktop.
Save edm00se/7e462a206baf670e367c to your computer and use it in GitHub Desktop.
iFrame resizing dynamically by the height of the content of the destination frame.
<!-- Include early for reference by the iframe itself -->
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
<!-- the onload triggers the resize against its own content -->
<iframe name="Stack" src="http://my.server.com/path/to/destination.html" frameborder="0" scrolling="no" id="iframe" onload='resizeIframe(this);' />
<!-- src: http://stackoverflow.com/questions/9975810/make-iframe-automatically-adjust-height-according-to-the-contents-without-using/9976309#9976309 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment