| Example 5 << >> | book |
| XUL | HOME |
| 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> |
| 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 |
| The default Mozilla CSS is used. |
| @import url(chrome://global/skin); |