如何在同一选项卡中打开侧边栏链接?

发布于 2025-01-16 01:21:36 字数 548 浏览 3 评论 0原文

有没有办法在 WebExtension 侧边栏中打开当前活动选项卡的链接?我不想在新选项卡中自动打开链接。我正在谈论常规链接:

<a href="https://www.example.com">Example</a>

我尝试过的事情:

  • 将任何 target 值添加到 a 元素似乎对任何值都没有达到预期的效果。
  • 调用 window.location.replace 将打开侧边栏中的链接,而不是当前活动的选项卡。
  • 使用 browser.tabs.query 获取当前选项卡并为唯一结果设置 tab.url 不会执行任何操作(即使我已添加 tabs > manifest.json 的权限)。

此时此刻,我觉得这可能是不可能的。是这样吗?

Is there a way to open a link in a WebExtension sidebar to the currently active tab? I don't want to automatically open the link in a new tab. I'm talking about regular links:

<a href="https://www.example.com">Example</a>

Things I've tried:

  • Adding any target value to the a element does not seem to have the desired effect for any value.
  • Calling window.location.replace opens the link in the sidebar instead of the currently active tab.
  • Getting the current tab by using browser.tabs.query and setting tab.url for the sole result does nothing (even though I have added the tabs permission to manifest.json).

At this point, I'm kind of thinking this might not be possible. Is this the case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文