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 7

Generally no, code running for a web page in one tab is isolated from the rest of the browser activity. The isolation is a basic and fairly obvious security measure.

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?

Securely and things like that use a combination of techniques, like a back-end filter, browser add-ons, etc.

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.

A browser extension can open, close, and modify tabs. It can also take screenshots and interact with scripts on the page. See the tabs API for details.

As already noted, regular scripts are restricted to their own domain.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.