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

210
Views
Clear local storage on closing all tabs or entire browser

How can I clear the local storage by closing all the tabs of the same domain (not closing one tab) or the entire browser? Session storage is not useful here as it cant share data with other tabs, so I haven't used session storage here. If I use event listeners like beforeunload, it is getting triggered even on page refresh, So what is the possible way to implement this concept in React?

Upon trying with taking count of tabs on loading and unloading, still, it is causing problems when there is one tab remaining. Can anyone please help me with an idea for this concept?

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

0

Use sessionStorage. There's a trick that involves writing token to localStorage that would tell the sessionStorage that there's shared data between tabs which can be retrieved using that token. See https://medium.com/@marciomariani/sharing-sessionstorage-between-tabs-5b6f42c6348c

I will try to paste some snippets from there, but really I don't know if that's allowed

about 4 years ago · Juan Pablo Isaza Report

0

You might want to look at the Broadcast Channel API

https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API

This API allow you to communicate between tabs, iframes, etc. sitting on the same origin.

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!