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

137
Views
onunload and pagehide event not firing after refresh

I have a 2 page application, where one is a parent page which opens the second page using window.open(url). I am watching for onunload or pagehide event from the child page. Both events are fired for the first time when child page opens(as expected) then when I refresh the child page the events are fired again but after that on close or refresh none of the events are triggered. Here is a sample code:

parent page

const newWindow = window.open(url);
newWindow.onunload = () => console.log('Unload event fired');
newWindow.onpagehide = () => console.log('PageHide event fired');

Both onunload & onpagehide events are recorded till first refresh of the child page. After refresh, If I try to refresh the page again or close the tab none of the event is recorded.

Here I am refreshing the child page which window.open opens. Also the url domain for both parent and child are same.

Am I doing something wrong here?

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!