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

123
Views
Se muestra un texto justo después de que se active mi javascript

Escribí códigos javascript.

Al hacer clic en el botón, la ventana secundaria aparece y muestra un texto enviado desde la ventana principal mediante una función posterior al mensaje.

Mi código podría enviar un texto a la ventana secundaria, pero no se muestra ningún texto. El texto se muestra solo cuando sigo haciendo clic en el botón. No quiero que el texto desaparezca.

Creo que mi código está anulado por un script en blanco o algo así, aunque no escribo ningún otro código excepto el siguiente.

¿Tienes alguna solución para esto?

la ventana principal html

 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Parent Window</title> </head> <body> <input type="button" value="TEST_BUTTON" id="testButton"> <script> var testButton = document.getElementById('testButton'); testButton.addEventListener('click', function(event) { event.preventDefault(); var newWindow = window.open('./child_window.html', 'popupWindow', 'width=400,height=300'); newWindow.postMessage('this is a content from the parent window.', '*'); return false; },false); </script> </body> </html>

la ventana del niño html

 <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Pop Up Window</title> </head> <body> <h1 id="mainText"></h1> <script type="text/javascript"> var mainText = document.getElementById('mainText'); window.addEventListener('message', function(event) { console.log(event.data); this.mainText.innerText = event.data; }, false) </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Terminé esto usando localStorage en su lugar.

about 4 years ago · Juan Pablo Isaza Report
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!