问题
I'm currently making a Firefox extension using the Add-on SDK (widget).
What I'm trying to do upon the widget being clicked is: Identify all addresses on a webpage, highlight the addresses, and show a panel (attached to the widget) with links to Google Maps with the address.
The issue I am having is displaying a link in the panel. I have been able to open and display actual sites and HTML files in the panel, but would like to know how, if possible, to display a clickable link in the panel.
I have been all over the Panel API and have not personally discovered a way.
Any tips are appreciated. Thank you.
Edit: I am using add-on sdk version 1.13.2
回答1:
You can just use a local file like myFile.html placed in your data directory. From that file you can receive the port message show in the onClick function of the widget.
var panel = require("sdk/panel").Panel({
contentURL: require("sdk/self").data.url("myFile.html");
});
require("sdk/widget").Widget({
id: "addrs",
label: "Addresses",
contentURL: "https://maps.gstatic.com/favicon3.ico",
panel: panel,
onClick: function() {
panel.port.emit('addrs', arrayOfAddresses);
}
});
Read the Getting User Input section of the Panel docs for more info on structure of files and the code for myFile.html.
来源:https://stackoverflow.com/questions/16073930/how-do-i-display-a-link-in-a-panel-on-my-firefox-extension-using-the-add-on-sdk