Closing popup window created by Google Chrome extension

后端 未结 4 2220
抹茶落季
抹茶落季 2020-12-02 14:53

I\'m trying to create a Chrome extension that is a replacement for the Delicious bookmarklet. I know there\'s already an extension that does it, but the problem with that ex

4条回答
  •  情话喂你
    2020-12-02 15:14

    Try window.close(), but that probably wouldn't work either.

    As you are creating regular window (rather than browser action popup), then you can close it using chrome.tabs.remove() from a background page. You can also detect this window from a background page. Something like:

    chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
        if(changeInfo.status == "loading") {
            if(tab.url == "http://www.delicious.com/save") {
                chrome.tabs.remove(tabId);
            }
        }
    });
    

    I am not sure how Chrome treats created windows though - as tabs or windows. If as windows then above code will be a little different.

提交回复
热议问题