I am developing a Mozilla Add on. I am trying to open a tab.
According to https://addons.mozilla.org/en-US/developers/docs/sdk/1.0/packages/addon-kit/docs/tabs.html it is done using
console.log("before tab");
var tabs = require("tabs");
tabs.open("http://www.example.com");
But it is not working on my case.
I am doing that in the content script. I have a page called popup.html and a content called popup_script.js.
The code is reached because the message is logged.
Any idea?
Content scripts don't have access to "advanced" APIs, they can merely communicate with the extension. So your content script should send a message to the extension and the extension should open the tab then. Like this:
self.port.emit("openTab", "http://www.example.com");
And in main.js
:
panel.port.on("openTab", function(url)
{
var tabs = require("tabs");
tabs.open(url);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With