문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top