Created
September 28, 2021 23:33
-
-
Save westonganger/444efd36a4701ea98a4175d7ac185c27 to your computer and use it in GitHub Desktop.
Auto IFRAME Height
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
// AUTOMATIC IFRAME HEIGHT | |
document.querySelector('iframe#my-iframe').addEventListener('load', function(){ | |
this.style.height = this.contentWindow.document.body.offsetHeight + "px"; | |
this.style.width = '100%'; | |
this.style.maxWidth = '1200px'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment