Event Handling With XUL
In order to reference this handler from a XUL document, you need to add via a standard <script> element or programatically add it to the XulDomContainer. Script elements can go anywhere in your XUL files, but best practices call for putting them just below the root element:
Or added programatically:
In order to connect doClick() to an event generated by a UI element, you must add a reference to it in the appropriate attribute of that element. For buttons, you would add an onclick attribute, as in this example:
Other elements (such as menus) use the oncommand attribute instead and may have other event attributes that you can link to your event handlers (onselect, onfocus, onblur, etc.). Refer to the Mozilla XUL developer documentation for details.
To execute event handler methods when an application starts, add an entry in the window or dialog's onload attribute. You can use this as a way of initializing your applications. Note that comma-separated values are supported if you need to call more than one method: