关闭 chrome.runtime.openOptionsPage 的等效命令是什么?

时间:2020-12-22 03:56:45

标签: javascript google-chrome-extension

在 Chrome 扩展中,什么等同于 close to chrome.runtime.openOptionsPage?我试过了:

window.close();

chrome.runtime.closeOptionsPage();

这需要从选项页面本身调用。

更新

根据下面评论中的 wOxxOm,“window.close()”应该可以工作。所以这可能是我浏览器 Edge 中的一个错误。

wOxxOm 建议使用“chrome.tabs.remove”。但是,我在选项脚本中以这种方式使用它时出现错误:

chrome.tabs.getCurrent(function(tab) {
  chrome.tabs.remove(tab.id, function() { });
});

Error handling response: TypeError: Cannot read property 'id' of undefined

0 个答案:

没有答案