Possible Duplication of Question
This similar question has been raised many times, however those solutions do not work for me. In addition, some of the solutions stated as answers are quite similar to my example. Therefore, it should work. But, that is not the case.
Main Example tried:
<iframe src="example.html" id="preview" ></iframe>
JavaScript:
$(document).ready(function () {
var previewObject = document.getElementById('preview');
var iframeChrome = previewObject.contentDocument.documentElement;
var iframeOther = previewObject.contentWindow.document.body;
var height = Math.max(iframeChrome.scrollHeight, iframeOther.scrollHeight);
previewObject.height = height;
});
Additional detail:
The iframe contains a preview of a website in the same domain/directory, the iframe should not contain a scrollbar, but display the whole website in it's full height.