Access to another tab from one window

How does the browser handle multiple tabs? Are they a completely separate entity where interaction is impossible? I understand the concept of the browser sandbox and other security issues, but is it possible for the web page to interact with another tab in the browser?

Basically, my question is: if a user loads one web page in a new tab, is there a way to access the information of another tab that is already open or will be opened after?

I have one application concept that needs to know about another tab that is already open or open after my conceptual web page, but I don't know if this is possible.

+4
source share
5 answers

As far as I know, this is not possible. The browser will not allow you to manipulate the lower functions of the browser in a normal environment. He will ignore this or show a security error.

+4
source

I think there is no way to do this, except when both documents are written to communicate with each other (as in vBulletin's new windows). The only way to access tabs is to write browser add-ons.

+1
source

No access to other tabs on the client side.

However, I can imagine a scenario in which this can be done on the server side. Ask the user to log into your site on both tabs and use something like sockets to transfer data back and forth from one tab to another, using the server as an average person.

+1
source

If both pages belong to the same domain, you can use cookies or in HTML5 local storage.

+1
source

If you own other tabs, you can translate them to other tabs, and other tabs can be broadcast back to your tab, creating a practical communication channel between them.

This is called Inter-window messaging and uses LocalStorage .


To simply check if you are an active tab, use $(window).blur( ... ) or a similar technique using the library of your choice.

+1
source

Source: https://habr.com/ru/post/1497085/


All Articles