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

242
Views
How can I pass values between parent page js and child popup js?

My parent page js file script:

var PopupConnect = window.open("http://localhost:8080");
var popup_function = PopupConnect.CreateText();

My popup page js file script:

function CreateText() {
  var text = "random text";
  return json({
        result: text
      })
}

This js line in parent page runs fine which triggers a new tab in the browser:

PopupConnect = window.open

The error I am getting is in the line after it:

Uncaught TypeError: PopupConnect.CreateText is not a function

How can I call the js function in child page from the parent page js correctly? Is that even possible? And how can I pass back the result from CreateText function to the parent page js?

NOTE: The parent page is running on Python server & the child popup page is running on Node.js server. Both pages of course are opened in the same browser.

Some people might suggest using localStorage.setItem and localStorage.getItem method but it doesn't work the two pages are running on different localhost ports and of course in production they will be running on different domains. FYI I have already tried this method and it didn't work.

UPDATE:

**I ended up using window.postMessage in parent page & have put addEventListener in child popup so once it receives the message it runs the js function. Now the issue I am facing is with timing things.

How can I insert a delay after window.open is called so the child page has time to fully load before parent page runs window.postMessage? I know there is something called 'await' but I assume this is for JS being used as backend not frontend? What is the best approach for this timing issue?**

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try it with Window.postMessage . hope to help you

Create an event listener in parent page & child page.

Send: Parent page sends -----message----> to child page (event listener) Reply: Child page sends -----message----> to parent page (event listener)

Update : about timming new page onload : you can send a message from new page to parent page when ready

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!