如何在同一选项卡中打开侧边栏链接?
有没有办法在 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 thea
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 settingtab.url
for the sole result does nothing (even though I have added thetabs
permission tomanifest.json
).
At this point, I'm kind of thinking this might not be possible. Is this the case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论