Last active
August 29, 2015 14:03
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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