Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
El mensaje no se muestra en el destino (comunicación entre ventanas)

Soy nuevo en el desbordamiento de pila: es un placer unirme a una comunidad como la suya.

Estoy enviando este mensaje porque estoy tratando de hacer una actividad relacionada con la comunicación entre ventanas, pero no puedo averiguar qué estoy haciendo mal. La tarea consiste simplemente en enviar un mensaje desde un origen y mostrarlo en la ventana de destino. El navegador web que estoy usando es Firefox 94.0.1 (64 bits).

Aquí tienes el código que he escrito:

ORIGEN

 <!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>Origin</title> </head> <body> <script> function sendMessage() { var destination = window.open("http://localhost/dew/cross_window_communication/destination.html"); destination.postMessage("Message from localhost", "http://localhost/dew/cross_window_communication/origin.html"); } </script> <form> <input type="button" onclick="sendMessage();" value="Send Message"> </form> </body> </html>

DESTINO

 <!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>Destination</title> </head> <body> <script> window.addEventListener ("message", function(event) { var message = event.data; var domain = event.origin; var targetWindow = window.opener; // The Window interface's opener property returns a reference to the window that opened the window. In other words, if window A opens window B, B.opener returns A. console.log("Message: " + message + ", Domain: " + domain + ", Opener: " + targetWindow), } ) </script> </body> </html>

Cuando hago clic en el botón, aparece la nueva ventana. Después de esto, accedo a la herramienta Firefox para desarrolladores web presionando el botón F12, pero de alguna manera el mensaje no se muestra en la consola.

Realmente agradecería si alguien pudiera ayudarme con esto.

Atentamente.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!