Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force focus a browser window using browser extension / plugin?

I am writing browser extensions for both chrome and firefox, and I am having a trouble finding how to focus a browser window that is currently out of focus but contains a tab that I want to focus.

Focusing a tab can be done when the browser window has focus. However, the browser window does not come to focus when I focus a tab inside it.

To make it clearer,

I have two chrome browser windows open, each containing multiple tabs. One of the window has a focus, and the other window contains a tab that I want to focus and show to the user. Though I can focus the tab so that it comes on top of other tabs, the browser window does not come on top of other browser windows.

I wonder if such API is available?

like image 248
Joon Avatar asked Sep 27 '13 01:09

Joon


1 Answers

Yes, in Firefox you have BrowserWindow.activate().

In Chrome you have chrome.windows.update(windowId, {focused: true})

like image 199
rsanchez Avatar answered Sep 18 '22 16:09

rsanchez