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

139
Views
comunicación entre mi página e iframe y envío de datos entre sí

Estoy tratando de comunicarme entre mi página y otro iframe que es otra página, que tengo,

En mi página de iframe, inserté este script en el encabezado

 if(typeof window !== 'undefined'){ window.addEventListener('message', event => { if (event.origin.startsWith('https://testpage.com/')) { document.querySelector('.home-title').classList.add('test'); event.source.postMessage('iframe', event.origin); } else { return; } }); }

y en mi página principal donde quiero comunicarme con mi iframe, tengo este código,

 <script> window.onload = function () { setTimeout(() => { const iframe = document.querySelector('iframe'); const iframeWindow = iframe.contentWindow; iframeWindow.postMessage("Hello there" , 'https://testIfame.com/'); alert('here alert pops-u'); }, 3000) window.addEventListener('message', function(event) { if (event.origin == 'https://testpage.com/'){ alert('asd'); } }, false); } </script>

La primera alerta funciona, aparece, pero nada más. Alguien me puede ayudar a resolver esto. Muchas gracias.

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!