Just omit the index parameter like this:
chrome.tabs.create({
windowId: tab.windowId,
url: request.url,
selected:
(localStorage[request.click] == "foreground")
});
Doing so tells chrome to use the default behavior of inserting a new tab.
I tried it with your extension and it seems to work.
Cheers
Rafael
On Mon, Jan 4, 2010 at 12:13 AM, Ionut Bilica <[email protected]> wrote:
> Tanks for your replay,
>
> I know about the "index" parameter, but you can not use it to get the
> right behavior.
>
> If I ctrl+click two links in tab A, my Chrome will show tabs A,B,C in
> this order. If I use tabs.create using index as you suggested, I get
> A, C, B. The last tab opened is inserted (using the index parameter)
> right after the current tab. So if you open more than one tabs, the
> last opened will be the one next to the active tab. Which is not the
> normal behavior.
>
> Chrome's positioning of new opened tab is clever. Not making it
> available for extension writers is not so clever.
>
> The extension I'm working on, and which gives me this headache is:
> https://chrome.google.com/extensions/detail/afalkcagoidkdjdlfoaicbanbfgoamoo
>
> Thanks again
>
>
> On Mon, Jan 4, 2010 at 12:36 AM, Mohamed Mansour <[email protected]> wrote:
>> The tab api has a "create" method as you have seen:
>> http://code.google.com/chrome/extensions/tabs.html#method-create
>> One of the parameters is "index", you can use that index to position that
>> tab anywhere in that window. So once you open a new link, you get its tab's
>> index from the tab object, and you increment 1. That value gets passed into
>> the "index" of the createProperties for chrome.tabs.create.
>> -Mohamed Mansour
>>
>>
>> On Fri, Jan 1, 2010 at 8:56 AM, ionut.bilica <[email protected]> wrote:
>>>
>>> In Chrome, when opening a link in a new tab, it is positioned after
>>> the last tab created to open a link from the current tab.
>>> How do I simulate this with chrome.tabs.create?
>>>
>>> Thanks
>>>
>>> --
>>>
>>> You received this message because you are subscribed to the Google Groups
>>> "Chromium-extensions" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/chromium-extensions?hl=en.
>>>
>>>
>>
>>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=en.