How can I achieve that if the content increases or decreases in size, does the iframe that contains it adjust?
If there is a JQuery plugin, pure JavaScript or a simple solution would be a great contribution since what I can only do is that it adapts to the content once it has finished loading, but not every time it is modified.
I attach the code that I have at the moment:
document.getElemenById('iframeToResize').onload = function() {
var newheight = this.contentWindow.document.body.scrollHeight,
newwidth = this.contentWindow.document.body.scrollWidth;
this.height = (newheight) + 'px';
this.width = (newwidth) + 'px';
};
<div id="iframeDiv">
<iframe src="dominio.com/pagina" width="100%" height="100px" id="iframeToResize" marginheight="0" frameborder="0"></iframe>
</div>
Sources of support: