popup link with the same target opens in different windows when clicked from different tab pages

40 Views Asked by At

I have a html page called home.html.

On that page I have a link to open a popup, the html code is as follows:

<a href='javascript: void(0);' onclick='window.open("popup.html", "myTarget", "width=1000,height=750");'>open popup</a>

https://jsfiddle.net/tLmgkjzy/

When I open home.html and click the link, the popup opens as expected. When I open home.html from a 2nd tab of Google Chrome and click the link, the popup opens in another window.

So despite the same 'target' name (myTarget), the popup opens in seperate windows.

How can I open the popup from the 2nd Google Chrome tab in the same popup window as the popup opened from the 1st Google Chrome tab?

thx Frederik

1

There are 1 best solutions below

0
akshayks On

Each browser tab has its own browsing context and that is why different tabs open different windows in this case. If you want to maintain context over multiple tabs, I suggest you use localStorage to maintain some state that you'd check each time you click on the link.