Can i open / focus a different tab within the same domain that i didn't open myself?

349 views Asked by At

I have two instances of my Angular App running in two different tabs, I would like to be able to let the user switch between them by pressing a button on the site.

I can communicate between the instances using the Broadcast Channel API, however calling window.focus() inside the inactive tab doesn't do anything. Since the messages are serialized / deserialized I also can't just send the window object over the channel.

I also tried getting access to the window instance of the inactive tab by setting window.name in it and then calling window.open('', otherName) in the active tab. That also doesn't work and just spawns a new empty tab.

A solution would have to work for existing instances of the app opened by the user, I know this would work if i just window.open'ed the second instance from the first one (Or iframed it or something similiar). I also know this would work using a browser extension but that also doesn't fit my use case.

If this simply isn't possible I will just build "tabs" into the application itself but just thought i would ask first since this way would be easier.

0

There are 0 answers