Łukasz Trzewik
Łukasz Trzewik

Reputation: 1165

Chrome extensions new tab as window popunder

I want to create a new window from a recently opened tab. The code that i currently have creates a new tab, then creates a new chrome window out of it , but the window is in a foreground despite being not focused. How do I make it appear in a background?

Here is my current code:

chrome.tabs.create({ url: url, active: false }, function (newTab) {
    chrome.windows.create({
        tabId: newTab.id,
        type: 'popup',
        focused: false,
        // incognito, top, left, ...
    }, function (window) {
        window.focused = false;
    });
});

Upvotes: 1

Views: 557

Answers (1)

Vinay
Vinay

Reputation: 7674

Try

chrome.windows.create({
    tabId: newTab.id,
    type: 'popup',
    focused: true,
    // incognito, top, left, ...
}, function (window) {
  chrome.windows.update(window.id, {focused:true});
});

Upvotes: 2

Related Questions