我只想從背景頁面創建一個新窗口並將其放回。我嘗試着重點:假,但它似乎並沒有成功。我試圖保存以前的windowId和tabId並在創建新窗口後更新它,但它也不能解決問題。創建一個窗口chrome,但後面有例外
你知道我們該怎麼做嗎?
這裏是我的代碼:
function saveTabId() {
// Get the current tab
chrome.tabs.getSelected(null,function(tab){
if (tab != 'undefined') {
if (tab.windowId != windowId) {
currentTabId = tab.id;
currentWindowId = tab.windowId;
}
chrome.windows.create({url:"http://www.google.com", width:100, height:100, top:0, left:0, focused:false}, function() {
chrome.tabs.get(currentTabId, function(tab) {
chrome.windows.update(tab.windowId, {}, function(w) {
chrome.tabs.update(tab.id, {selected:true});
});
});
});
}
});
}
我發起這個代碼在background.html的開始,當我刷新了擴展,窗口是在擴展選項卡上。
PS:更奇怪的是,窗口位於擴展選項卡頂部,當我更改此窗口中的選項卡時,即使我單擊並在另一個窗口中鍵入文本,新窗口也會保持在另一窗口的頂部。 。
謝謝,我不知道是否有可能直接在另一個下面...我只是在下一個答案中添加,重點放在良好的選項卡上,但實際上並不是必需的: ) – Farf