You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome扩展调用chrome.action.openPopup报错,版本122.0.6261.94求助

chrome.action.openPopup 调用报错:TypeError: 不是函数

根据Chrome扩展官方文档,在后台脚本中调用chrome.action.openPopup()应该能触发扩展弹窗,但我始终遇到以下错误:

Uncaught (in promise) TypeError: chrome.action.openPopup is not a function

我试过网上给出的解决方案,但问题依旧。我的Chrome版本是122.0.6261.94(官方版本,x86_64),但有其他人反馈用完全相同的代码可以正常运行。我已经准备了完整的示例代码来复现这个问题。

我现在怀疑:Chrome是不是在没有更新官方文档的情况下,悄悄取消了这个方法的支持?我查过不少同类问题,大多被关闭,而且提问者都表示那些所谓的解决方案根本没用。

完整代码文件

manifest.json

{
  "name": "Test Extension",
  "description": "Test Extension",
  "version": "1.0",
  "manifest_version": 3,

  "permissions": ["webNavigation"],
  "action": { "default_popup": "popup.html" },
  "background": { "service_worker": "background.js" }
}

background.js

chrome.webNavigation.onCompleted.addListener(
  async () => {
    await chrome.action.openPopup();
  },
  { url: [
    { urlMatches: 'https://example.org/' },
  ] },
);
<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Test Extension</title>
    <script src="popup.js"></script>
  </head>
  <body>
  </body>
</html>
document.addEventListener('DOMContentLoaded', () => {
  document.body.textContent = 'This is a test.';
});

内容的提问来源于stack exchange,提问作者BWStearns

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 17:03:15