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

94
Views
PostMessage get iframe value

I have two servers ( for example: localhost:3000 and http://example.com ). In the localhost, I have an iframe that is connected to http://example.com ( through src attribute ), so I've sawed a lot of answers that showed how to get data, but I didn't saw any that showed how to save it.

<!-- localhost:3000 -->
<iframe src="http://example.com" id="example"></iframe>

<script>
  let iframeCONTENT = null;
  // ^^^^ how do I fill this variable with the content of iframe
  
  let iframe = document.querySelector("#example");
  let iframeDocument = iframe.contentWindow || iframe.contentDocument || iframe.contentDocument;
  
  iframeDocument.postMessage("", "*")
</script>

<!-- http://example.com -->

 <h1>Hello World!</h1>
 <p>Blabla!</p>

<script>
    window.addEventListener("message", (e) => {
       console.log(document.body)
    }, false)
</script>

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!