0

Lets say I have a page with button on it. When user clicks button - new window A opens.

I want that window A to be open only once, so even if user opens new tab and goes to same page with that button and clicks it - it shouldn't open 2nd window A and should instead focus on previous already open Window A.

Any solution to this?

Since chrome has new process for every tab - the variables are not shared between pages.

My solution was to ping update time to local storage every 5 seconds from original window A.

If user clicks button on new tab, it would check local storage and if Last update was less than 5 seconds ago - don't open window but if it was more than 5 seconds ago - open new window as it could mean the window A crashed or was closed or force closed.

That seems to be bad solution for Internet Explorer though as I think it would cause performance drop on page.

Any alternative solution to this?

  • 1
    http://stackoverflow.com/questions/16977590/opening-only-one-instance-of-url-using-window-open – ThreeSidedCoin Sep 10 '15 at 08:41
  • @ThreeSidedCoin that doesn't work, it's only for one tab window. But if I open new tab and click button again - another window will open as chrome does not share variables or window references between tabs. – Artur Leitis Sep 10 '15 at 09:00
  • Perhaps look at http://stackoverflow.com/questions/2236828/javascript-communication-between-tabs-windows-with-same-origin/12514384#12514384 – Jack Allan Sep 10 '15 at 09:03

0 Answers0