![](/img/trans.png)
[英]Google Chrome: can't getElementById from chrome extension
[英]Can't close opening chrome windows from setTimeout in callback from chrome extension
因此,我的代碼的一部分如下:
for(i = 0; i < torrentLinks.length; i++) {
chrome.windows.create({ url: torrentLinks[i] }, function(newWindow) {
setTimeout(function() {
chrome.windows.remove(newWindow.id);
}, 4000);
});
}
我面臨的問題是我可以打開想要的窗口,但它們永遠不會自動關閉。 我假設setTimeout函數無法正常工作,所以我希望對此有所幫助。
注意:使用擴展程序時,每天都有不同數量的窗口打開,因此無論有多少窗口,我都需要關閉。
提前致謝
for(i = 0; i < torrentLinks.length; i++)
{
chrome.windows.create({url:torrentLinks[i]}, function(newWindow)
{
window.setTimeout(function() //Forgot the window part
{
chrome.windows.remove(newWindow.id);
}, 4000);
});}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.