当前位置:Linux教程 - Linux - XUL教程之三

XUL教程之三



        
    XUL Tutorial - 1.3 - The Chrome URL
    Previous Contents Reference Next
    XUL Tutorial - The Chrome URL

    下面的段将介绍引用XUL文件和其他的chrome文件.
    The Chrome URL

    XUL文件能被以正常的HTTP URL就像HTML(or any type of URL)被引用一样进行引用. 可是,在Mozilla chrome系统中安装的包 能利用特殊的chrome URLs被引用.在chrome目录中的文件将被安装,但是你能够注册一个你自己的.

    ,安装的包有不需要安全限制的好处,者对许多应用是必要的.chrome URLs具有越过URL类型的好处,因为他们会自动地处理多个皮肤和本地化

    chrome URL的基本语法如下:

    chrome:// /content /

    是构件的名称, 例如messenger or editor.

    Example: chrome://messenger/content/messenger.xul

    这里的例子引用messenger窗口. 你可以指向皮肤的部分文件,通过把 content 替换成 skin 并改变文件名. 类似的,你可以指向一个文件,该文件是本地化的一部分,通过把content替换成locale.

    你应当认为chrome URL是文件URL的特殊类型 (that is, file:// URLs)但是其根目录实是Mozilla的chrome,可是,有一个附加的特征 .chrome的皮肤和本地化部分被映射到当前的设置,而chrome URL不做改变,但是指向改变是什么?

    Mozilla能够算出当前的皮肤和当前的语言并映射合适的目录到 chrome URLs.在chrome那些RDF文件盒contents.rdf告诉Mozilla如何进行这种映射.这种方法能使用任何皮肤和语言,而引用chrome文件的URLs不需要改变.例如缺省的navigator.css可以应用为:

    chrome://navigator/skin/navigator.css

    如果你改变浏览器的皮肤在别的什么地方, chrome URL 不需要改变, even through its real location changes.

    chrome系统包浏览器的内容部分,当前的皮肤和当前的语言组合在一起形成一个用户界面,这里是一些更多的例子:

    chrome://messenger/content /messenger.xul
    chrome://messenger/content/mime.js
    chrome://messenger/skin/images/reply.jpg
    chrome://messenger/locale/messenger.dtd

    对于子包,可以使用同样的结构.下面的例子是引用书签窗口

    chrome://communicator/content /bookmarks/bookmarks.xul

    You can enter chrome URLs anywhere normal URLs can be used. You can even enter them directly into the URL bar in a Mozilla browser window.

    Remember too, that you can also refer to XUL files with regular file URLs also. You might do this to test a file without having to install a package.

    You might also see chrome URLs without specified filenames, such as:

    chrome://global/skin/

    This type of reference will automatically select an appropriate file from that directory. For skins, a file with the name of the package and a css extension is selected. In the above example, the file global.css is selected.

    For content files, a file package.xul is selected and for locale files, a file package.dtd is selected, where package is the name of the package. This is a convenient shorthand syntax.

    (Next) In the next section, we will look at how to create manifest files and install packages.
    XUL Tutorial - 1.3 - The Chrome URL
    Previous Contents Reference Next
    发布人:fanyoou 来自: