Necesito actualizar el javascript en la plantilla HTML a continuación para demostrar postMessage.
El propósito de esto, enviaré el mensaje a mi propia ventana.
Necesito completar las secciones TODO con el código requerido.
No entendí cómo actualizar window.postmessage como encabezado de nivel 2.
También necesito ayuda para las secciones TODO que se muestran a continuación.
Gracias.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial- scale=1.0"> <title>Document</title> </head> <script> function processMessage(message) { console.log("postMessage:", message); window.postmessage() } function receiveMessage(event) { console.log("Origin:", event.origin); window.addEventListener('message', function(e) { var origin = e.originalEvent.origin || e.origin; if(origin !== 'http://127.0.0.1:9898') return; console.log('received message: ' + e.data, e); }, false); // (2) Remove the "message" event listener // TODO - YOUR CODE GOES HERE } } // add event listener for postMessage // TODO - YOUR CODE GOES HERE // dispatch a postMessage to the main window // TODO - YOUR CODE GOES HERE </script> <body> <h1>Chapter 16 - HTML Scripting - XDM (Cross Domain Messaging)</h1> </body> </html>