|
阅读:4418回复:0
一个极简单的firefox扩展的例子(入门级) -- 跟firefox打招呼
这是一个很简单的例子,已经入门了的就不用看了.
安装这个扩展后重启firefox,在浏览器的网页显示区点右键,可以看到下拉菜单中有一个菜单项"HelloFirefox",点击这个选项,会出现一个"Hello Firefox!"的提示框. 代码很简单,就不作什么解释了. 安装文件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">
<em:id>{3912615B-BD5B-40aa-942C-36C4F66AA378}</em:id>
<em:name>HelloFirefox</em:name>
<em:version>0.1</em:version>
<em:description>Say hello to FIREFOX!</em:description>
<em:creator>Land Wen</em:creator>
<em:homepageURL>http://www.dotdee.com</em:homepageURL>
<em:iconURL></em:iconURL>
<em:aboutURL></em:aboutURL>
<em:updateURL>http://www.dotdee.com/update.rdf</em:updateURL>
<em:file>
<Description about="urn:mozilla:extension:file:hellofirefox.jar">
<em:package>content/hellofirefox/</em:package>
</Description>
</em:file>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.7</em:minVersion>
<em:maxVersion>1.5</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>功能实现文件hellofirefox.xul如下: <?xml version="1.0"?>
<overlay id="hellofirefox" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- 添加自定义的菜单子项 -->
<popup id="contentAreaContextMenu">
<menuitem id="hellofirefox" label="HelloFirefox" accesskey="H" oncommand="alert('Hello, Firefox!');"/>
</popup>
</overlay>
完整文件在附近里. |
|
|