0

I am trying to create an extension that changes to the next tab in an array of tabs and it also has to be able to loop back to the beginning. I have been pounding away at this for a couple of days now and can not for the life of me figure it out.

The way this extension works is it listens for a tab to update, then it runs one function before this nextTab function.

Here is what I currently have as my nextTab function:

function nextTab(){
     // get the current window
    chrome.windows.getCurrent(function(win)
    {
        // get an array of the tabs in the window
        chrome.tabs.getAllInWindow(win.id, function(tabs)
        {
            var tabIds = [];
            for (i in tabs)
            tabIds.push(i);
                for (var i = 0; i < tabIds.length; i++)
                {
                    var tab = tabs[tabIds[i]];
                    chrome.tabs.update(tab.id, { selected: true});
                }

        });
    });
};

So far it will cycle through the tabs from the looks of it when I run it. But it always ends up on the last tab. Does anyone have an easier way to do this or can give me any tips on what I am doing wrong?

Hudspeth
  • 136
  • 13
  • i cant see where you are checking for "am i at the last tab" . where is it ? – kommradHomer Apr 05 '12 at 06:16
  • For some reason I am unable to utilize console.log();. The results never seem to post into the developer tools. So I can not check that way, and if I use alert(); then the box is off the screen in the top left and I can not see what it says. – Hudspeth Apr 05 '12 at 07:15
  • http://stackoverflow.com/questions/3829150/google-chrome-extension-console-log-from-background-page check this for log problem please – kommradHomer Apr 05 '12 at 07:19

0 Answers0