问题描述
我正在尝试对被点击的小部件做什么:识别网页上的所有地址,突出显示地址,并显示一个面板(附加到小部件),并带有指向Google地图的地址。
我遇到的问题正在显示面板中的链接。我已经能够打开并显示面板上的实际网站和HTML文件,但想知道如何在面板中显示可点击的链接。
我已经遍布Panel API,并没有亲自发现一个方法。
任何提示,赞赏。谢谢。
$ b编辑:我正在使用附加的sdk版本1.13.2
您可以在 data
目录中使用本地文件,如 myFile.html
。从这个文件中,你可以在窗口小部件的 onClick
函数中接收到端口消息显示。
var panel = require(sdk / panel)。Panel({
contentURL:require(sdk / self)。data.url(myFile.html);
}); ($ {
id:addrs,
label:Addresses,
contentURL:https:/
require(sdk / /maps.gstatic.com/favicon3.ico,
panel:panel,
onClick:function(){
panel.port.emit('addrs',arrayOfAddresses);
}
});
阅读部分文档以获取更多关于文件结构和代码的信息为myFile.html。
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
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.
这篇关于如何使用附加SDK在我的Firefox扩展的面板中显示链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!