0

I am opening a popup chrome window.

let popup = window.open(redirectUrl, '_blank');

I want to take the variable set in the localstorage in that window, before it closes. I have written code as

popup.onbeforeunload = (e) => {
   console.log(popup.localStorage.abc);
}

But this line is not getting executed. I debugged,Debugger is not even going inside the method. Please help me in what I am doing wrong or is there any other way?

  • 1
    Does this answer your question? [Capture the close event of popup window in JavaScript](https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript) – Pratansyah Jun 14 '21 at 13:05
  • I have tried the other method also, by setting time interval. But it is not giving me localStorage access – Gunjan Chanana Jun 15 '21 at 06:49
  • Are you perhaps opening a pop up for different domain? If you are then it is simply impossible for security reasons – Pratansyah Jun 15 '21 at 09:07

0 Answers0