Question

I'm using Erik Vold's toolbarbutton API with Mozilla's Addon-SDK and was wondering if there is a way linking a menu-item in order to open a mail programm onclick.
For a widget this is trivial since I can just add a <a href="mailto:xxxxx"></a> to the HTML of the corresponding panel.
But what about the toolbarbutton-menu? Is there anything like type: "email" for instance which would allow modifying the toolbarbutton API?

EDIT:
What I already tried without success:
giving the menu-item href attribute (including class text-link)
adding anchor element as childNode to menu-item

Was it helpful?

Solution

You don't need a link, you can simply "request" that URL yourself:

var {ToolbarButton} = require("toolbarbutton");
var {Request} = require("sdk/request");
ToolbarButton({
  ...
  onCommand: function () {
    try {
      Request({url: "mailto:foo@example.com"}).get();
    }
    catch (e) {
      // Ignore "no data will be returned" exception
    }
  }
});

This request will have exactly the same effect as the user clicking the link - no data will be returned but the mail application window will open.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top