Is it possible for JS in Tab A to detect if Tab B is Google, for example, or any other type of tab. And if so , could it close Tab B using JS?
7 Replies
Tabs can interact with other tabs that are on the same domain, but browsers have quite strict restrictions when it comes to tabs seeing data from other domains.
One way you can do this is using web sockets. But you have to have a Server and a common/shared communication protocol for it to work.
This would be a different thing, but if browsers have restrictions on it for the clear security risks, then how does software like Securly block pages? It seems that the browsers would not allow it, but it is allowed and used by many schools. How does that work?
the only way to know about other tabs is if your tab spawned them. As the opener it could receive messages back from other tabs. (see postMessage: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage ) There are some response headers that would also control what an opener could do with that tab handle. (such as "Cross-Origin-Opener-Policy": https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cross-Origin-Opener-Policy ) For instance, navigating away from initial URL.