Search code examples
firefoxgoogle-chrome-extensionfirefox-addonfirefox-addon-sdk

Firefox extension content page


I am working on porting a chrome extension to a firefox extension.

The chrome extension has a "index.html" page that loads up in a tab when clicking the extension . Is this possible in a firefox extension?


Solution

  • Assuming you are using the add-on SDK and adapting the tutorial that is available at Adding a Button to the Toolbar, the following should do what you have described.

    var buttons = require('sdk/ui/button/action');
    var tabs = require("sdk/tabs");
    
    var button = buttons.ActionButton({
      id: "my-extension-index-button",
      label: "Open index.html",
      icon: {
        "16": "./icon-16.png",
        "32": "./icon-32.png",
        "64": "./icon-64.png"
      },
      onClick: handleClick
    });
    
    function handleClick(state) {
      tabs.open("index.html");
    }