Javascript 如何在不关闭弹出窗口的情况下创建选项卡
当我从弹出窗口创建选项卡时,弹出窗口将关闭,bc selected为true。此时将选择新选项卡:Javascript 如何在不关闭弹出窗口的情况下创建选项卡,javascript,google-chrome-extension,Javascript,Google Chrome Extension,当我从弹出窗口创建选项卡时,弹出窗口将关闭,bc selected为true。此时将选择新选项卡: chrome.tabs.create({'url': 'http://www.google.com', 'selected' : true }); 当所选的为false时,弹出窗口仍然存在,但新选项卡尚未聚焦: chrome.tabs.create({'url': 'http://www.google.com', 'selected' : false }); 如何将这两者结合起来,使新选项卡和
chrome.tabs.create({'url': 'http://www.google.com', 'selected' : true });
当所选的为false
时,弹出窗口仍然存在,但新选项卡尚未聚焦:
chrome.tabs.create({'url': 'http://www.google.com', 'selected' : false });
如何将这两者结合起来,使新选项卡和弹出窗口同时可见?我玩了chrome.tabs.move
,但我觉得我走错了方向。当你选择另一个窗口时,绝对无法保持弹出窗口的打开状态
如果要推迟选择窗口,可以先创建它,准备好后,可以使用
有点晚了,但万一其他人也需要这个。我找到了一条绕道而行的路
API:如果先将当前选项卡设置为“固定”,然后在其他窗口中创建/删除/选择其他选项卡,然后取消固定当前选项卡,则当前选项卡将保持打开状态,因此弹出窗口将不会关闭
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});
});
});
穆罕默德,非常感谢,这正是我要找的!Mohamed,我实现了,但是弹出窗口关闭了:((horiworld:是的,弹出窗口应该关闭,因为您现在集中在另一个选项卡/窗口中。在选择另一个窗口/选项卡时,绝对无法保持弹出窗口打开。
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});
});
});