Question

In my system I have a 'cool feature' that is available in another window, I open it using js:

var newWindow = window.open(...);

But I need to have only one window with the 'cool feature', so if user tries to open it one more time, it should bring the existing window to the top, I know it can be done like:

newWindow.focus()

But the problem is, how to save the newWindow object in order to share it with other browser tabs where my system is opened? I tried to use cookies and localStorage, but they are built to store string-string values, not objects. JSON serialization strips all methods and the object becomes useless.

I there anything else I can do to get it working?

Était-ce utile?

La solution

As far as I know this is impossible. A parent window may connect to a child, but the other tabs are completely unrelated. If you could do this, it could be a massive security issue. Imagine a bank using a child window, and malicious code in some other tab trying to connect to it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top