To autosize iframes, I use onload=“resizeIframe(this)” and a simple external js file:
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
Seems to work fine, except that if I refresh the page it doesn’t resize - but does if I refresh again. This continues with each refresh - resizes, then doesn’t, resizes, then doesn’t, etcetera. I realise it’s unlikely that users will do this, but I want the resize to be reliably applied.
Worth mentioning that it’s WordPress, and a plugin is used to load partial page content.
My js knowledge is small, and I’ll be appreciative of any sensible advice.