简体   繁体   中英

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?

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");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM