How do I display a link in a panel on my Firefox Extension using the Add-on SDK?

五迷三道 提交于 2019-12-12 03:54:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!