Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Unknown macro: {scrollbar}

Example: Hello World in XUL

All XUL files have the .xul extension, but are otherwise written in XML-compliant markup language. The DTD is pretty standard:

<?xml version="1.0"?>

And you must define a style sheet as well (this one is the default):

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

Now you must declare a window, which is the root element of every XUL object. The id and title attributes are the only things you should change if you are using the reference rendering engine:

<window id="hello_world" title="Hello World" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

A text box is the most basic XUL element. By default, the box will be horizontally oriented. Within the box you can put buttons, fields, and text. In this example, it's a simple box with one button:

<box>
<button id="Hello World!" label="Hello World!"/>
</box>

Then provide a closing tag for your window element:

</window>

Now type this into your favorite XML editor and try it out. Then check out the XUL reference to experiment with other elements and attributes: http://developer.mozilla.org/en/docs/Category:XUL_Elements

  • No labels