因为项目的需要,一些功能需要在火狐上面实现,一点也不了解火狐插件的开发,网上的中文资料也少得可怜,
没办法,只好自己研究一下英文文档,慢慢开发了,在这里备份一下。
学编程,当然是从Hellow,world开始啦。那么我们看看火狐插件的Hellow,world是怎么做的吧
一、创建目录
- 随便在一个文件夹里面,新建一个文件夹,名字随意,最好以自己的插件名称命名。我这里做演示,就命名为 test
- 在test文件夹下面创建一个文件夹,命名chrome。
- 在test文件夹下面创建两个文件,分别为install.rdf、chrome.manifest
- 在chrome文件夹下面创建一个文件夹,命名为content。
- 在content文件夹下面创建一个文件,命名为test.xul。
- 每个文件的编码一定要是utf-8的!否则显示中文会出错!!!
最后得到如下文件:
二、配置install.rdf文件
install.rdf是一个安装清单,的信息。其中内容我们可以设置为:
<?xml version="1.0"?> <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <Description about="urn:mozilla:install-manifest"> <!-- id:一个独特的识别字符串。字符串的形式为 扩展名@域创造者。 --> <em:id>test@hcsem.com</em:id> <em:version>2.0</em:version> <em:type>2</em:type> <!-- Front End Metadata --> <em:name>状态栏</em:name> <em:description>在状态栏上面显示字符串</em:description> <em:creator>黄聪</em:creator> <em:homepageURL>http://developer.mozilla.org/en/docs/Creating_a_status_bar_extension</em:homepageURL> <!-- Describe the Firefox versions we support --> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>1</em:minVersion> <em:maxVersion>30.0.*</em:maxVersion> </Description> </em:targetApplication> </Description> </RDF>