When I create a tab from popup, popup window will close, bc selected is true. The new tab is selected:
chrome.tabs.create({'url': 'http://www.google.com', 'selected' : true });
When selected
is false
, popup remains, but new tab hasn't been focused:
chrome.tabs.create({'url': 'http://www.google.com', 'selected' : false });
How to combine this, having the new tab AND the popup visible at the same time? I played around with开发者_如何转开发 chrome.tabs.move
, but I feel I'm on the wrong way.
A little late, but in case anyone else needs this too. I found a way around the API: If you first set the current tab to pinned, then create/remove/select other tabs in other windows, then unpin the current tab, the current tab will remain open, and as a result the popup will not close.
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
const currentTab = tabs[0];
// pin the current tab:
chrome.tabs.update(currentTab.id, {pinned: true}, function(t){
// do what you need to do here:
chrome.tabs.update(someTabId, {}, function(){
// un-pin the current tab
chrome.tabs.update(currentTab.id, {pinned: false});
});
});
There is absolutely no way keeping the popup opened while you select another window.
If you want to defer selecting the window, you can first create it, and when your ready, you can select it with chrome.tabs.update.
chrome.tabs.create({url: 'http://www.google.com', selected: false}, function(tab) {
chrome.tabs.update(tab.id, {selected: true});
});
精彩评论