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

能否在Chrome扩展中打开chrome://、brave://开头的特殊链接?

Chrome扩展跳转chrome://extensions/shortcuts报错的解决方案

直接通过<a href="chrome://extensions/shortcuts">的方式跳转Chrome内部协议页面会触发Not allowed to load local resource错误,这是Chrome的安全限制,不允许普通页面上下文直接导航到chrome://开头的内部管理页面,可通过以下两种方案实现跳转:

  • 方案1:扩展自有页面(弹出页、选项页)内直接调用API跳转
    把原a标签替换为可绑定点击事件的元素,无需额外申请扩展权限即可使用:
    页面示例代码:

    <button id="openShortcutBtn">配置扩展快捷键</button>
    

    对应JS逻辑:

    document.querySelector('#openShortcutBtn').addEventListener('click', () => {
      chrome.tabs.create({ url: 'chrome://extensions/shortcuts' })
    })
    
  • 方案2:内容脚本注入的按钮跳转走消息转发
    如果跳转按钮是内容脚本注入到普通网页的元素,无法直接调用tabsAPI,需要将请求转发给后台服务 worker 处理:
    内容脚本代码:

    // 内容脚本中绑定注入按钮的点击事件
    document.querySelector('#openShortcutBtn').addEventListener('click', () => {
      chrome.runtime.sendMessage({ type: 'OPEN_SHORTCUT_PAGE' })
    })
    

    后台服务 worker(manifest V3配置的service_worker)代码:

    chrome.runtime.onMessage.addListener((msg) => {
      if (msg.type === 'OPEN_SHORTCUT_PAGE') {
        chrome.tabs.create({ url: 'chrome://extensions/shortcuts' })
      }
    })
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.04 05:27:04