using JavaScript to display text

Sometimes we have to display text dynamically in the UI though, which XUL alone can't do. Most times JavaScript is used for that. C++ is sometimes used as well, it uses a similar technique for displaying localized content though, and it uses the same type of files for localization.

Sample XUL: openLocation.xul, calling some JS code

<?xml version="1.0"?>
<!DOCTYPE dialog SYSTEM "chrome://communicator/locale/openLocation.dtd">
<dialog id="openLocation" ... title="&caption.label;" onLoad="onLoad();">
<script type="application/x-javascript" src="chrome://communicator/content/openLocation.js"/>
        <menuitem value="0" id="currentWindow" label="&topWindow.label;"/>

Sample JavaScript: openLocation.js

function onLoad()
  dialog.main = document.getElementById("openLocation");
  dialog.openTopWindow = document.getElementById("currentWindow");
  if (!browser) {
    // No browser supplied - we are calling from Composer
    // Change string to make more sense for Composer
    dialog.openTopWindow.setAttribute("label", "Existing Navigator window");
    // change title to 'Open Location with Mozilla'"title", "Open Location with Mozilla");