Showcase project embedding an <iframe />
displayed in full height in host document.
<iframe />
is the way to go when embedding your website into any non third-party website with no configuration and while sandboxing style 🎨and security 🔒.
However, building a responsive iframe 💻📱is pretty tricky. Especially displaying the iframe
in full height in the host document.
- The
<iframe />
window calculates its height 📏 and sends a message 📫(with a specific syntax) to its parent using thepostMessage
API. - The parent has a listener 👂to this message 📬 and dynamically sets the height of the
<iframe />
This project is hosted on CodeSandbox.
This project is inspired 💡& "forked" 🌱from the Making IFrames Responsive article from bitsofcode and the related source code.