在Firefox扩展弹出窗口内的HTML文件之间切换?

发布于 2025-01-27 11:19:53 字数 617 浏览 1 评论 0原文

我一直在试图将Chrome Extension移到Firefox上。大多数代码工作正常,除了这一件事。扩展弹出窗口具有 tab按钮顶部应该在不同的html文件之间切换(内部)弹出窗口)单击时。但是,当单击按钮时,扩展名只是冻结/崩溃。

这是“联系”选项卡按钮的代码的示例:

 contactTab = document.getElementById("contact-tab")
 
 contactTab.addEventListener("click", function() {
     location = "contact.html"
 })

在我使用location.href的chrome版本中,它的工作正常,此问题仅在Firefox上。我已经尝试使用location.href位置window.location.location,但是什么都没有。

如何在Firefox扩展弹出窗口中的HTML文件之间切换?

I've been trying to port my Chrome extension over to Firefox. Most of the code worked fine, except for this one thing. The extension popup has tab buttons at the top which are supposed to switch between different html files (inside the popup) when clicked. However, when the buttons are clicked, the extension simply freezes/crashes.

Here’s an example of the code for the "contact" tab button:

 contactTab = document.getElementById("contact-tab")
 
 contactTab.addEventListener("click", function() {
     location = "contact.html"
 })

In the Chrome version of my extension I used location.href and it worked perfectly fine, this problem is only on Firefox. I’ve tried using location.href, location and window.location, but nothing has worked.

How do I switch between html files in a Firefox extension popup?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2025-02-03 11:19:53

在JavaScript文件中添加EventListener,DO:

window.location.href="yourhtml.html";

html的路径基于root Directory。

Add an eventListener in your JavaScript file and do:

window.location.href="yourhtml.html";

Path to HTML is based on root directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文