Last active
February 21, 2016 09:21
-
-
Save ianchadwick/0461c6a90041bda92d38 to your computer and use it in GitHub Desktop.
Use postMessage to tell the parent window the size of the current window height - for parent window implementation see https://gist.github.com/ianchadwick/a4e277d641bf739063c9
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
<script> | |
/** | |
* For parent window implementation details | |
* @see https://gist.github.com/ianchadwick/a4e277d641bf739063c9 | |
*/ | |
(function (speed) { | |
if (parent === window) { | |
// no parent frame! | |
return; | |
} | |
// make sure the scroll bars are hidden on the html element | |
document.documentElement.style.overflow = 'hidden'; | |
var height = 0; | |
var watchForChanges = function () { | |
height = window.document.body.getBoundingClientRect().height; | |
parent.postMessage('iframe-height|' + window.location + '|' + height, '*'); | |
setTimeout(watchForChanges, speed); | |
}; | |
watchForChanges(); | |
}(200)); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment