You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a great feature of embedded iframe within markup. However, it does not support resizing. I think it would be really helpful to have some plugin to listen to embedded iframes and resize them based on message they post.
This could be simple postMessage with specific contract.
function findIframe(frameElement) {
var iframeList = document.querySelectorAll('iframe');
for (var i = 0; i < iframeList.length; ++i) {
if (iframeList[i].contentWindow === frameElement) {
return iframeList[i];
}
}
}
function receiveMessage(e) {
try {
var data = JSON.parse(e.data);
var height = data['iframe-height'];
var iframe;
if (height && (iframe = findIframe(e.source))) {
iframe.style.height = height + 'px';
}
} catch (err) {
}
}
window.addEventListener('message', receiveMessage, false);
The text was updated successfully, but these errors were encountered:
KalachevDev
changed the title
Add ability resize iframe when embedded application posts message about height change
Add ability to resize iframe when embedded application posts message about height change
Jul 4, 2024
There is a great feature of embedded iframe within markup. However, it does not support resizing. I think it would be really helpful to have some plugin to listen to embedded iframes and resize them based on message they post.
This could be simple postMessage with specific contract.
And also html-extension with functionality of resizing iframes based on content height: https://github.com/diplodoc-platform/html-extension/blob/main/src/runtime/HtmlController.ts#L19
The text was updated successfully, but these errors were encountered: