Last active
September 23, 2017 12:50
-
-
Save abitdodgy/4d578e9c9ae8dfd2ecadc0adfefa481e to your computer and use it in GitHub Desktop.
Resizes iframe to fit content on window resize and load events.
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
var _pc_resizeIFrame = function(iframe) { | |
iframe.height = iframe.contentDocument.body.scrollHeight; | |
} | |
document.querySelectorAll(".pc-iframe").forEach(function(iframe) { | |
window.onload = function () { | |
_pc_resizeIFrame(iframe); | |
}; | |
window.onresize = function () { | |
_pc_resizeIFrame(iframe); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment