Trying to adjust the frame height to fit the loading content.
HTML
<iframe src="forum/viewforum.php?f=6" width="100%" frameborder="0"
scrolling="no" onload="resizeIframe(this)"></iframe>
JS
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
How can I stop the function from running until everything is loaded. I tried:
document.addEventListener('DOMContentLoaded', function() {
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
}, false);
and
$(document).ready(function(){
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
});
but it does not work. Any suggestions?