Faculty
function adjustIframeHeight() {
const iframe = document.getElementById('myIframe');
if (iframe) {
// Send a postMessage to the iframe to request its content height
iframe.contentWindow.postMessage({ type: 'getIframeHeight' }, '*');
}
}
// Listen for postMessage responses from the iframe
window.addEventListener('message', function (event) {
if (event.data && event.data.type === 'iframeHeight') {
const iframe = document.getElementById('myIframe');
if (iframe) {
iframe.style.height = event.data.height + 'px';
}
}
});
// Adjust the iframe height initially and whenever the content changes
window.onload = adjustIframeHeight;
window.onresize = adjustIframeHeight;