Last active
August 29, 2015 14:19
-
-
Save aheinze/211636e42c0c209850f1 to your computer and use it in GitHub Desktop.
seamless-iframe.js
This file contains 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
/** | |
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