首页 > 解决方案 > 关闭 chrome.runtime.openOptionsPage 的等效命令是什么?

问题描述

在 Chrome 扩展中,接近 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

标签: javascriptgoogle-chrome-extension

解决方案


推荐阅读