I try to receive the viewport from the iframe, and i'm using postMessage
but i want to run this code every time app is resized.
Retool query
const newViewport = {...viewport}
parent.postMessage(newViewport, "*")
My app:
window.addEventListener('message', (event) => {
if (event.data) {
setHeight(event?.data?.height);
}
}, false);
<iframe
title="Retool App"
src={retoolURL}
style={{
height: `${height}px`;
}}
frameBorder="0"
/>
Other testings:
- i tried to use
resize
event withaddEventListener
but doesn't work apparently. - i tried to use
iframe.contentWindow.document.body.scrollHeight
but i was getting this error:
Blocked a frame with origin "http://localhost:8000" from accessing a cross-origin frame.
thank you for your help