Javascript 如何在Mac OS X Snow Leopard中运行XUL应用程序?
我正在尝试在Mac OS X中创建一个XUL“Hello World”应用程序。我从下载XULRunner,然后。。。没有一个奏效。所以,我仔细看了看,发现我遵循了他的指示。不幸的是,它还不起作用。我甚至可以用这个命令运行应用程序Javascript 如何在Mac OS X Snow Leopard中运行XUL应用程序?,javascript,firefox,xul,xulrunner,osx-leopard,Javascript,Firefox,Xul,Xulrunner,Osx Leopard,我正在尝试在Mac OS X中创建一个XUL“Hello World”应用程序。我从下载XULRunner,然后。。。没有一个奏效。所以,我仔细看了看,发现我遵循了他的指示。不幸的是,它还不起作用。我甚至可以用这个命令运行应用程序 /Library/Frameworks/XUL.framework/xulrunner-bin $PWD/application.ini 但是,不会显示任何窗口,也不会打印任何错误。当我尝试使用firefox-app运行应用程序时,也会发生这种情况 有什么不对劲?
/Library/Frameworks/XUL.framework/xulrunner-bin $PWD/application.ini
但是,不会显示任何窗口,也不会打印任何错误。当我尝试使用firefox-app
运行应用程序时,也会发生这种情况
有什么不对劲?还有,有人知道一些有用的教程吗?这也是一个可以接受的答案:)
提前谢谢
文件内容
application.ini
文件的内容是:
[App]
Vendor=Me
Name=Zull
Version=1.0
BuildID=31052011
ID=zull-xul@zull.com
[Gecko]
MinVersion=2.0
MaxVersion=2.*
chrome/chrome.manifest
的内容是:
content zull file:content/
<?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">
<caption label="Hello World"/>
</window>
pref("toolkit.defaultChromeURI", "chrome://zull/content/main.xul");
chrome/content/main.xul
的内容是:
content zull file:content/
<?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">
<caption label="Hello World"/>
</window>
pref("toolkit.defaultChromeURI", "chrome://zull/content/main.xul");
我在这里只能看到一个明显的错误。chrome.manifest文件的内容应为:
content zull content/
通常,您可以将
-jsconsole
标志添加到命令行。这将打开错误控制台,并经常向您显示错误所在。根据Wladimir Palant的建议,我将chrome/chrome.manifest的内容从
content zull file:content/
到
然后,接下来,我在根app dir中创建了一个chrome.manifest
文件,其内容是
manifest chrome/chrome.manifest
这是必需的,因为在XULRunner 2.0中,chrome.manifest
的默认位置是根应用程序目录
但是,错误没有为注册chrome软件包chrome:///User/brandizzi/sandbox/zull/main.xul
持久化。然后,我明白了:为了解决这个问题,我在defaults/preferences/prefs.js
中使用了main.xul
文件的完整路径:
pref("toolkit.defaultChromeURI", "chrome:///User/brandizzi/sandbox/zull/main.xul");
我只是把它改成了chrome路径
pref("toolkit.defaultChromeURI", "chrome://zull/content/main.xul");
…而且成功了
尽管这是一堆愚蠢的错误,但现在已经解决了。他对我很有帮助。另外,Wladimir建议使用XULRunner的
-jsconsole
选项(例如在/Library/Frameworks/XUL.framework/XULRunner-bin~/sandbox/zull/application.ini-jsconsole
)非常有用。控制台显示消息无法读取chrome清单文件…/zull/chrome.manifest
。我将chrome.manifest
复制到应用程序根目录,然后得到消息没有为chrome注册chrome包:…/main.xul
。我认为这是另一个问题,所以我将把你的问题标记为答案,然后再问另一个问题,因为-jsconsole
在某种程度上就是我想要的。