Below is my code which I am using to load iframe content with dynamic height of the iframe content:
<iframe id="form-iframe"
style="margin: 0; width: 100%; height: 100%; border: none; overflow: hidden;"
src="URL" width="300" height="150" scrolling="no"
onload="AdjustIframeHeightOnLoad()">
</iframe>
function AdjustIframeHeightOnLoad() {
document.getElementById("form-iframe").style.height = \
document.getElementById("form-iframe").contentWindow.document.body.scrollHeight
+ "px";
}
But by using above code in html I am getting below error in console log
Error: Permission denied to access property "document"
How can I read the height from the content of my iframe to set my iframe
-container to the same size?