Focus on a browser tab with Javascript

Asked

Viewed 901 times

1

With Javascript, you can focus on a specific browser tab, assuming I know which tab? If so, how?

1 answer

1

Lucas,

as mentioned here there is no effective and 100% reliable method to trigger a specific tab of the browser.

You can use the function window Focus.(), but remember that it will probably be locked in most browsers, so don’t let your application depend on this function.

Example:

var myWindow = window.open("", "", "width=200, height=100");   // Abre uma nova janela
myWindow.document.write("<p>A new window!</p>");         // Adiciona um texto na nova janela
myWindow.focus();                                     // Passa o foco para nova janela.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.