2.6. Good Coding Practices for XUL

Developing XUL applications means creating XML documents. The best way to do this is by hand, as there are no good GUI builders for XUL yet. It is very important that sloppy habits left over from HTML are stopped before they start. Listing 2.10 shows a typical piece of legacy HTML code.

Listing 2.10. Unstructured HTML development.
<HTML><HEAD>
  <STYLE>
    P { font-size : 18pt; }
  </STYLE>
  <SCRIPT>
    function set_case(obj)
    {
      if (obj.value)
        obj.value = obj.value.toUpperCase();
      return true;
    }
  </SCRIPT>
</HEAD><BODY BGCOLOR="yellow">
  <P>Enter a name</P>
  <FORM>
    <INPUT TYPE="text" ONCHANGE="set_case(this)">
</FORM>
</BODY></HTML>

This code is not very modern, but it works. XUL will not stand for this lazy treatment. It ...

Get Rapid Application Development with Mozilla™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.