Skip to content

Instantly share code, notes, and snippets.

@curtisj44
Last active April 21, 2022 21:34
Show Gist options
  • Save curtisj44/8837a4e40692478194c1fd40823db6ad to your computer and use it in GitHub Desktop.
Save curtisj44/8837a4e40692478194c1fd40823db6ad to your computer and use it in GitHub Desktop.
Responsive Test - Match iframe height to height of page contents
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