Example 5     <<      >>      book     

Some menu items can be disabled by setting the disabled attribute to the value true.

  XUL  HOME     

  xul1.xul  
With the id attribute an element is uniquely determined. The function getElementById selects this element and the function setAttribute in this case selects attribute disabled and assigns the relevant value
<?xml-stylesheet href="css1.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical" >
     <menubar>
          <menu value="AAA">
               <menupopup>
                    <menuitem value="Enable" type="radio" name="group"
                              oncommand = "document.getElementById('resize').setAttribute('disabled','false') "/>
                    <menuitem value="Disable" type="radio" name="group" checked = "true"
                               oncommand = "document.getElementById('resize').setAttribute('disabled','true') "/>
                    <menuseparator/>
                    <menuitem id="resize" value="Resize" disabled="true"
                                        oncommand = "resizeBy(20,20)"/>
               </menupopup>
          </menu>
     </menubar>
</window>

  xul2.xul  
If the element is not identified by id attribute a more lenghty and risky procedure must be choozen. The function getElementsByTagName selects all elements with given name. The function item(2) selects the third element of this name in the document (the numbering starts from 0)
<?xml-stylesheet href="css1.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical" >
     <menubar>
          <menu value="AAA">
               <menupopup>
                    <menuitem value="Enable" type="radio" name="group"
                              oncommand = "document.getElementsByTagName('menuitem').item(2).setAttribute('disabled','false') "/>
                    <menuitem value="Disable" type="radio" name="group" checked = "true"
                               oncommand = "document.getElementsByTagName('menuitem').item(2).setAttribute('disabled','true') "/>
                    <menuseparator/>
                    <menuitem value="Resize" disabled="true"
                                        oncommand = "resizeBy(20,20)"/>
               </menupopup>
          </menu>
     </menubar>
</window>

  CSS  HOME     

  css1.css  
The default Mozilla CSS is used.
@import url(chrome://global/skin);