Last active
April 21, 2022 21:34
-
-
Save curtisj44/8837a4e40692478194c1fd40823db6ad to your computer and use it in GitHub Desktop.
Responsive Test - Match iframe height to height of page contents
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
const setFrameHeight = (frameElement, index) => { | |
frameElement.style.height = 'unset'; | |
const iframeElement = document.querySelectorAll('iframe')[index]; | |
const targetHeight = `${ iframeElement.contentWindow.document.body.scrollHeight }px`; | |
iframeElement.style.height = targetHeight; | |
} | |
document.querySelectorAll('.frame').forEach((frameElement, index) => setFrameHeight(frameElement, index)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment