I am trying to develop a firefox addon using an API I developed. The addon shows some links but when I click that link it opens in a new window. I want them to open in a new tab.
It depends on the API you’re using for your add-on and how you’re adding the link.
I am using AddOn SDK for this purpose and links are simply added using
tag with target=’_blank’
So these are links inside a panel? By default I think those links open within that panel correct?
I think what you’ll have to do is add a port.emit
on your links. It should emit a message with the link to open to your index.js
/main.js
which will do this:
var tabs = require("sdk/tabs");
tabs.open("http://www.example.com");
My guess is that this tabs
API opens the tab in the currently focused (meaning most recent) navigator:browser
type window.
It worked .
Awesome! May you please share your code so it can help others.
Actually I did not do any thing to change , when I install the addon and
open then link it opens correctly in a new tab of current active window .
But when I do jpm run and addon opens in a new window. In that case if I
click a link it opens in new window. So I think it depends on browser
settings whether you open links in new tab or window. Since when we do jpm
run our initial browser settings dont hold.