Skip to content

Instantly share code, notes, and snippets.

@ianchadwick
Last active February 21, 2016 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianchadwick/0461c6a90041bda92d38 to your computer and use it in GitHub Desktop.
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
<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