Kudayar Pirimbaev
Kudayar Pirimbaev

Reputation: 1320

Firefox: Window similar to Chrome extension window

Sample Chrome extension opens a window after pressing its corresponding button in the upper-right corner of the browser (near the menu list opener). How to open such window for Firefox extension (using jpm preferably).

Upvotes: 0

Views: 44

Answers (2)

Christos Papoulas
Christos Papoulas

Reputation: 2578

A simple solution to open a new window when the button of your extension is pressed is the following:

main.js:

var tabs = require("sdk/tabs");
var { ActionButton } = require("sdk/ui/button/action");

var button = ActionButton({
    id: "my-button",
    label: "my button",
    icon: {
      "16": "./icon-16.png",
      "32": "./icon-32.png",
      "64": "./icon-64.png"
    },
    onClick: handler
});

function handler() {
    tabs.open("https://developer.mozilla.org");
}

Make sure that the icons of your extension should be in the data folder.

Look at mozilla developers documentation for more information:

Upvotes: 1

cviejo
cviejo

Reputation: 4398

You can achieve the same functionality in a firefox add-on using toggle buttons. Specifically take a look at attaching panels to buttons.

Upvotes: 2

Related Questions