Active tab not working when using multiple Chrome windows.

227 views
Skip to first unread message

Assaf

unread,
Dec 8, 2014, 10:52:04 AM12/8/14
to chromium-...@chromium.org
This is my extension:
It takes your current/active tab URL and does something...
The problem is, that when there are several open Chrome windows, the "active" tab is a wrong one.
Example:
I have 3 tabs in one Chrome window. Each tab shows a different URL, i.e. URL1, URL2, URL3.
URL 2 is the active tab. 
Now I drag tab 3 (with URL3) out of Chrome to create a new Chrome window which contains only one tab (URL3)

On this new window, I click the extension button, and instead of takign URL3 as the active one, it takes URL2 !
Weird...how it can be solved?

Rob Wu

unread,
Dec 8, 2014, 10:57:51 AM12/8/14
to Assaf, Chromium-extensions
When I look in your extension's source code, I see

     chrome.tabs.query({
         active: true
     }, function callback(tabs) {
         //set first input to url of active tab
         document.forms[0].elements[0].value = tabs[0].url;

This is wrong, if there are multiple windows, then the number of active tabs is greater than 1. Add currentWindow:true to get the active tab in the currently activated window.

Kind regards,
 Rob
 https://robwu.nl

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1fb3dd77-37ef-4549-884f-e46b6b412a21%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Reply all
Reply to author
Forward
0 new messages