Menu

Cross-Origin Iframe Resizing Without the Feedback Loop
📰

Cross-Origin Iframe Resizing Without the Feedback Loop

DEV Community: frontend·Edmond Rätzel·18 days ago
#Ri6b9XWj
#devtofrontend#devto#dev#embed#height
Long article (1229 words) — no AI summary yet.
Reading 0:00
15s threshold

A photo gallery fits neatly inside a 600-pixel iframe. Then someone opens the comments panel. The submit button disappears below the frame, a second scrollbar appears, and the host page has no idea anything changed.

Increasing the default height only moves the problem. A narrow screen produces more grid rows. A different language wraps captions onto extra lines. Client photo selection changes the visible content.

This is a practical integration problem for photo and video client galleries , where reviewing and downloading happen inside the same interface. The implementation below is a standalone design for a service you control, not a description of any particular product’s internals.

Let the child measure and the parent decide

The host cannot inspect a cross-origin iframe’s DOM. Instead, the embedded page measures its content and sends a small message. The parent validates that message before updating the iframe.

The browser provides this communication channel through window.postMessage() .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.