Skip to content

Instantly share code, notes, and snippets.

View LukeFF's full-sized avatar

Lukas Thoma LukeFF

  • Ravensburg - Germany
  • 00:45 (UTC +02:00)
View GitHub Profile
@LukeFF
LukeFF / parent.html
Last active September 7, 2016 10:10
automatic Iframe resizing on same domain
<iframe id="superFrame" src="..." style="width: 100%; border: none;" onload="resizeIframe(this)" scrolling="no"></iframe>
<script type="text/javascript">
function resizeIframe(iframe) {
if(iframe) {
iframe.height = '';
iframe.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}
}
</script>
@LukeFF
LukeFF / iframe.html
Last active September 7, 2016 10:00
automatic Iframe resizing without Cross-Origin issues
<body onLoad="resizeParent();">
<script type="text/javascript">
function resizeParent() {
var height = document.getElementsByTagName("html")[0].scrollHeight;
window.parent.postMessage(["setIframeHeight", height], "*");
}
</script>
</body>