码迷,mamicode.com
首页 > 其他好文 > 详细

Mozilla Firefox扩展(Extensions)开发——xulrunner

时间:2015-12-24 20:55:46      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:

XULRunner is a Mozilla runtime package that can be used to bootstrap XUL+XPCOM applications that are as rich as Firefox and Thunderbird. It provides mechanisms for installing, upgrading, and uninstalling these applications. XULRunner also provides libxul, a solution which allows the embedding of Mozilla technologies in other projects and products.

关于XULRunner的介绍:https://developer.mozilla.org/en-US/docs/Mozilla/Projects/XULRunner

下面介绍XULRunner开发一个桌面应用的例子:《Getting statred wiht XULRunner》

Step1:下载XULRunner

下载地址:http://ftp.mozilla.org/pub/xulrunner/releases/latest/

Step2:安装XULRunner

windows下解压放在固定目录即可,例如:C:\program files\xulrunner

Setp3:创建应用目录结构 

+ myapp/
|
+-+ chrome/
| |
| +-+ content/
| | |
| | +-- main.xul
| | |
| | +-- main.js
| |
| +-- chrome.manifest
|
+-+ defaults/
| |
| +-+ preferences/
|   |
|   +-- prefs.js
|
+-- application.ini
|
+-- chrome.manifest

 Step4:配置Application.ini

[App]
Vendor=XULTest
Name=myapp
Version=1.0
BuildID=20100901
ID=xulapp@xultest.org

[Gecko]
MinVersion=1.8
MaxVersion=200.*
Step5:配置Chrome manifest

chrome/chrome.manifest

content myapp content/
根目录下的chrome.manifest
manifest chrome/chrome.manifest

Step6:配置Preference

prefs.js

pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");

/* debugging prefs, disable these before you deploy your application! */
pref("browser.dom.window.dump.enabled", true);
pref("javascript.options.showInConsole", true);
pref("javascript.options.strict", true);
pref("nglayout.debug.disable_xul_cache", true);
pref("nglayout.debug.disable_xul_fastload", true);
Step7:配置XUL

main.xul

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="My App" width="300" height="300" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/javascript" src="chrome://myapp/content/main.js"/>

  <caption label="Hello World"/>
  <separator/>
  <button label="More >>" oncommand="showMore();"/>
  <separator/>
  <description id="more-text" hidden="true">This is a simple XULRunner application. XUL is simple to use and quite powerful and can even be used on mobile devices.</description>

</window>
main.js

function showMore() {
  document.getElementById("more-text").hidden = false;
}
Step8:运行application

运行命令:xulrunner.exe application.ini

注意考虑路径。

运行截图:





Mozilla Firefox扩展(Extensions)开发——xulrunner

标签:

原文地址:http://blog.csdn.net/anda0109/article/details/50395536

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!