Resize iframe to wrap it's content every time it changes it src
<p>I managed to resize the iframe to wrap its content with this code:</p>

<pre><code>var frameHeight = document.getElementById("fibertjekIframe").contentWindow.document.body.scrollHeight;
$(this).height(frameHeight);
</code></pre>

<p>And it works fine the first time page loads, but inside that iframe is a form and when user submits the form, he is redirected to another page within that iframe. I want that iframe to resize based on its content as well. </p>

<p>I was hoping this would work:</p>

<pre><code>// Auto resize of the Fibertjek Iframe
$("#fibertjekIframe").on("load", function () {
    var frameHeight = document.getElementById("fibertjekIframe").contentWindow.document.body.scrollHeight;
    $(this).height(frameHeight);
});
</code></pre>

<p>The function is called every time there is new src loaded inside the iframe but for some reason I am getting the old height of the iframe so it remains the same.</p>

<p><strong>EDIT:</strong> I have investigated a little more and I found out that even after form submission (in the iframe) and after the redirection, the src attribute of the iframe remained the same so I assume it is still referring to the old page, even though it has been redirected. The only idea how to overcome this I've got, is to set source of the iframe to the page that I was redirected to after form submit, but that is not convenient and right solution ... </p>