Overview
An onchange attribute is an event listener to the object for the Event change. A change event is fired in different ways for different XUL Input Elements as listed below:
-
onchange
- Type: script code
TextBox | When Enter key is pressed |
Radio/Check Box | When the state is changed |
Select List | When the selected item is changed |
What is accessible
The script context at this point can only access the following things:
- Global Values/Functions i.e. window, document, or any of the functions/objects/variables bound to the window object
- Event object
Example
<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="findfile-window" title="Find Files" orient="horizontal" xmlns="https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="text/javascript"> function myFunction(e){ /* Do something cool here or just say the below */ alert(e.target.nodeName); } </script> <textbox id="find-text" onchange="return myFunction(event);"/> </window>