I need to set the mainContainer
class height
to the iframe height on page load.
Right now its setting the height BUT its cut. Maybe this code is wrong? const iframeHeight = document.getElementById('productIFrame')[0].contentWindow.document.body.offsetHeight + 'px';
<div class="mainContainer">
<iframe id="productIFrame" src="https://sample.com" title="" width="100%" height="100%" style="border: none"></iframe>
</div>
<style>
.mainContainer {
width: 100%;
}
</style>
<script type="text/javascript">
const iframeHeight = document.getElementById('productIFrame').contentWindow.document.body.offsetHeight + 'px';
document.getElementsByClassName("mainContainer")[0].style.height = iframeHeight;
</script>