« XUL Reference home
Type: unique id
A unique identifier so that you can identify the element with. You can use this as a parameter to getElementById() and other DOM functions and to reference the element in style sheets.


<button id="foo" label="Click Me" oncommand="doSomething()"/>

function doSomething(){
    var myButton = document.getElementById('foo');
    myButton.setAttribute('label','The button was pressed');

A more abstract version of the above would be a

<button id="foo" label="Click Me" oncommand="setWidgetLabel(this, 'I was pressed')"/>
function setWidgetLabel(idName, newCaption){
   document.getElementById( idName.id ).setAttribute('label',newCaption)

Not specifying the id attribute for a window or a prefwindow fills the console with the following warning message: Warning: Empty string passed to getElementById()

See also