Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>Microfrontends Shell</title>
<p><button id="message_button">Send message to child</button></p>
<div id="results"></div>
const iframeSource = "";
const iframe = document.createElement("iframe");
const messageButton = document.querySelector("#message_button");
const results = document.querySelector("#results");
iframe.setAttribute("src", iframeSource); = "450px"; = "200px";
function sendMessage(msg) {
iframe.contentWindow.postMessage(msg, "*");
messageButton.addEventListener("click", function(e) {
window.addEventListener("message", function(e) {
results.innerHTML =;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.