style.css

#myframe {
    width: 500px;
    min-height: 300px;
    overflow: hidden;
    border: 0;
}

html

<iframe src="./iframe.html" id="myframe"></iframe>

js

var iframe = document.getElementById('myframe')

window.addEventListener('DOMContentLoaded', function () {
    iframe.addEventListener('load', autoHeight)
})

function autoHeight() {
    var frame = iframe
    var sub = frame.contentDocument ? frame.contentDocument : frame.contentWindow.document
    iframe.height = sub.body.scrollHeight
}

iframe.html (하위 html)

body {
    overflow: hidden;
}