A straightforward way to use postMessage to communicate with an iframe with React. Send the message from the parent element: const myiframe = document.getElementById('myIframe') myIframe.contentWindow.postMessage('message', '*'); Found inside Page 336For the address book iFrame to communicate with the game iFrame, it would have to go through the parent frame. postMessage On the pair of MessagePort objects is where we define our message event listeners. Finally, there's a third If you continue to use this site we will assume that you are happy with it. // Reference AppMeasurement code on a parent page from within an iframe and send an image request parent.s.pageName = "Page Name on Hosted Window"; parent.s.t(); Use postMessage and event listeners. Found insidepostMessage()SOP 1 (browserhacker.com)IFrame Accept Solution Reject Solution. Note that both parent and child need to include the jQuery postMessage javascript, and for communication to be enabled in browsers that don't support window.postMessage, the child page must know the exact parent URL (in this example, that is done by passing the parent location into the Iframe using a hash param in the Iframe src attribute). In your VF, you do window.onload () function, where you postmessage to your lightning component with body 'loaded'. If you send or receive message from different iframes, you can include a parameter to indicate where the message comes from. @guest271314 I don't think I need to define a 'message' event handled inside the iframe. Except it's not working. This is the origin of my iframes parent window. is there any other solution? The iframe.contentWindow.postMessage() call sends a message to the IFrame, while the window.parent.postMessage() sends a message back to the main page. postMessage to iframe parent not received cross-domain scorm. Connect and share knowledge within a single location that is structured and easy to search. No initial message from the main window Send data from an iframe to its parent window // Called from the iframe window.parent.postMessage(message, '*'); Where message is a string. Found inside Page 12A shadow DOM enables us to write components that are projected into the parent DOM without being part of the parent DOM. A way around many of the JavaScript drawbacks is to fall back to the mentioned