/* The variables "data" and "dialog", by convention, are generic JS Objects with properties corresponding to corresponding document elements. For example, in this sample .xul file, the "input" property of the variable data refers to the document element with id "data.input". The properties of these objects are set in the functions initData() and initDialog(), respectively. */ var data; var dialog; /* initData is called by the onload handler. It creates the data Object and sets each property of interest. */ function initData() { data = new Object; data.input = document.getElementById( "data.input" ); data.output = document.getElementById( "data.output" ); } /* initDialog does likewise for the dialog object and properties. */ function initDialog() { dialog = new Object; dialog.input = document.getElementById( "dialog.input" ); dialog.output = document.getElementById( "dialog.output" ); dialog.close = document.getElementById("dialog.close"); } /* loadDialog is called by the onload handler. It should load the dialog (UI) controls from appropriate data fields and otherwise set up for display of the dialog. */ function loadDialog() { } /* onLoad is the onload handler. It initializes the data, then the dialog, then loads the initial dialog contents. */ function onLoad() { window.arguments[0].Observe( window, "sample", "onLoad called" ); // Init data. initData(); // Init dialog. initDialog(); // Fill dialog. loadDialog(); } /* onClose is the onclick handler for the dialog's close button. It issues the "close" command to the underlying C++ code (which will presumably close the window). */ function onClose() { // Close the window. data.execute.setAttribute( "command", "close" ); } XUL Dialog Tests This dialog demonstrates use of XUL dialogs. You can cause the dialog to be opened from C++ or JavaScript. The dialog can be displayed modally or not. Input: Output: Non-modal C++... Non-modal JS... Modal C++... Modal JS... Close