Skip to content

Instantly share code, notes, and snippets.

@aheinze
Last active August 29, 2015 14:19
Show Gist options
  • Save aheinze/211636e42c0c209850f1 to your computer and use it in GitHub Desktop.
Save aheinze/211636e42c0c209850f1 to your computer and use it in GitHub Desktop.
seamless-iframe.js
/**
USAGE:
Just load the script in the page loaded by the iframe.
<script src="seamless-iframe.js"></script>
**/
(function(doc, iframe){
// exit if page is not within an iframe
if (!iframe) return;
setInterval((function(h, idle) {
idle = function() {
if (doc.body && doc.body.scrollHeight != h) {
h = doc.body.scrollHeight;
iframe.style.height = h+'px';
}
return idle;
};
return idle();
})(-1), 50);
})(document, window.frameElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment