diff --git a/channel-messaging-basic/page2.html b/channel-messaging-basic/page2.html index 3929fec5..d5d36c11 100644 --- a/channel-messaging-basic/page2.html +++ b/channel-messaging-basic/page2.html @@ -14,6 +14,8 @@ window.addEventListener("message", onMessage); function onMessage(e) { + if (!e.ports) return; + output.innerHTML = e.data; // Use the transfered port to post a message back to the main frame e.ports[0].postMessage("Message back from the IFrame");