I have an extension that needs to know what URL is on the active tab, but the problem is that when I open a second chrome window there are 2 active tabs, in the webmaster to
Make your query to select the last focused Window:
chrome.tabs.query({ active: true, lastFocusedWindow: true }, function (tabs) {
//...
});
Note: Better don't take currentWindow: true
because:
The current window is the window that contains the code that is currently executing. It's important to realize that this can be different from the topmost or focused window.
Source: http://developer.chrome.com/extensions/windows.html#current-window
Use chrome.windows.getCurrent() (or .getLastFocused()
, right below it) to get the current window, then look for the active tab in the tabs
property of the returned window.