window.addEventListener on a message emitted from an iframe
问题 I have two html files. The first is called post.html and it registers an event listener on the window and posts a message to the window: <html> <head> <script> window.addEventListener("message", function(event) { console.log("found event in post!", event) }); window.postMessage({ 'data': ["some data"] },"*"); </script> </head> <body> </body> </html> I have a second html file called listner.html that just listens for a message from the window and loads post.html as an iframe: <html> <head>