mozbrowseractivitydone
mozbrowserasyncscroll
mozbrowseraudioplaybackchange
mozbrowsercaretstatechanged
mozbrowserclose
mozbrowsercontextmenu
mozbrowserdocumentfirstpaint
mozbrowsererror
mozbrowserfindchange
mozbrowserfirstpaint
mozbrowsericonchange
mozbrowserloadend
mozbrowserloadstart
mozbrowserlocationchange
mozbrowsermanifestchange
mozbrowsermetachange
mozbrowseropensearch
mozbrowseropentab
mozbrowseropenwindow
mozbrowserresize
mozbrowserscroll
mozbrowserscrollareachanged
mozbrowserscrollviewchange
mozbrowsersecuritychange
mozbrowserselectionstatechanged
mozbrowsershowmodalprompt
mozbrowsertitlechange
mozbrowserusernameandpasswordrequired
mozbrowservisibilitychange
DOMContentLoaded
abort
afterprint
afterscriptexecute
beforeprint
beforescriptexecute
beforeunload
blur
cancel
canplay
canplaythrough
change
click
close
connect
contextmenu
durationchange
emptied
error
focus
hashchange
input
invalid
languagechange
load
loadeddata
loadedmetadata
loadend
loadstart
message
offline
online
open
pagehide
pageshow
play
playing
popstate
progress
readystatechange
rejectionhandled
reset
seeked
seeking
select
show
sort
stalled
storage
submit
suspend
timeupdate
toggle
unhandledrejection
unload
volumechange
waiting
The following tables and sections describe the event handler that are valid for most XUL elements. The events listeners can be attached using addEventListener and removed using removeEventListener.
Some of the events can be attached using attributes as well. When attaching event listeners using attributes, be aware that only one listener can be attached at a time. Any previously attached listeners are disconnected. The attribute name is the event name with an 'on' prefix.
broadcast
event is executed when the attributes of the element (such as a broadcaster) being listened to are changed. The event handler should be placed on an observer.CheckboxStateChange
event is executed when the state of a <checkbox> element has changed.close
event is executed when a request has been made to close the window when the user presses the close button.commandupdate
event is executed when a command update occurs on a <commandset>
. This event would be used to update the disabled status of its commands.DOMMenuItemActive
event is executed when a <menu>
or a <menuitem>
has been hovered or highlighted.DOMMenuItemInactive
event is executed when a <menu>
or a <menuitem>
in no longer hovered or highlighted.popuphidden
event is executed when a <menupopup>
, <panel>
or <tooltip>
has become hidden.popuphiding
event is executed when a <menupopup>
, <panel>
or <tooltip>
is about to be hidden.popupshowing
event is executed when a <menupopup>
, <panel>
or <tooltip>
is about to become visible. The default action of the event can be prevented to prevent the popup to appear.popupshown
event is executed when a <menupopup>
, <panel>
or <tooltip>
has become visible.<radio>
element has changed.ValueChange
event is executed when the value of an element, <progress>
for example, has changed.Event | Description |
---|---|
blur |
The opposite of the focus event, the blur event is passed after an element loses the focus. |
change |
This event is sent when the value of the textbox is changed. The event is not sent until the focus is moved to another element. |
click |
This event is sent when a mouse button is pressed and released. You can determine which mouse button was clicked by retrieving the |
dblclick |
This event is like the click event except it is only sent when the user double clicks with the mouse. This is an alternative to checking the detail property in the click event. |
DOMMouseScroll |
This event is sent when the mouse wheel is moved, whether it results in content being scrolled or not. |
focus |
The focus event is sent to an element when it receives the focus. Once an element has the focus, keyboard events are sent to it. The focus can be changed by clicking on another element, by pressing TAB to switch to the next element in the tab order sequence, or by pressing 'back TAB' to switch focus to the previous element in the tab order. |
keydown |
The keydown event is sent to an element that has the focus while a key is pressed but not released. |
keypress |
The keypress event is sent to an element that has the focus when a key is pressed and released. When the user presses a key, the keydown event is sent first, followed by the keypress event and then the keyup event. In a textbox, a user can normally hold down a key to repeat a character In this case, multiple sets of key events are sent (as if the user pressed the same key repeatedly). |
keyup |
The keyup event is sent to an element that has the focus when a key is released. |
load |
This event is sent to the window after it has been fully loaded. You should place this event handler on the window element. This event may also be used on the image element, or an element that accepts an image attribute, and will be fired when the image has finished loading. For images, this event does not bubble up the element tree, so it will not conflict with the window's load event. |
mousedown |
This event is sent when the mouse is pressed on an element but not released. |
mousemove |
This event is sent repeatedly as the mouse is moved over an element. |
mouseout |
This mouseout event is sent to an element when the user moves the mouse outside the element. This event is the reverse of mouseover. |
mouseover |
This event is sent to an element when the mouse first moves over an element. You can use this event to provide feedback to the user. |
mouseup |
This event is sent when the mouse is released on an element. |
select |
This event is sent to a listbox or tree when an item is selected. |
unload |
This event is sent to a window when the window has closed. This is done after the close event. You should place this event handler on the window element. |
Event | Description |
---|---|
DOMAttrModified |
This event is sent to an element when one of its attributes is modified. In the event handler, you can retrieve the attribute that was modified using the event's |
DOMNodeInserted |
This event is sent when a node is added as a child of a element. If you capture this event at the document level, you can be notified of document changes. |
DOMNodeRemoved |
This event is sent when a node is removed from an element. If you capture this event at the document level, you can be notified of document changes |
Warning: It should be noted that the addition of any mutation event listeners to a document degrades the performance of subsequent DOM operations in that document, and that removing the listeners later does not mitigate or reverse the effect. See Mutation events for more details and Mutation observers for a more efficient alternative.
Event | Description |
---|---|
broadcast |
The event handler should be placed on an observer. The broadcast event is sent when the attributes of the element (such as a broadcaster) being listened to are changed. |
This event is sent when a request has been made to close the window when the user presses the close button. If you place an event handler on the window element, you can trap the window close. If you call event.preventDefault() within the listener the window will not close. Note that the close event is only fired when the user presses the close button on the titlebar; (i.e. not File -> Quit) use the unload event to capture all attempts to unload the window. |
|
command |
This event handler is called when an element is activated. How it is activated varies for each element and in many cases, there are several ways to activate an element. For example, a button can be activated by clicking on it with the mouse or by pressing ENTER while it has the focus. Menus can be activated by selecting them with the mouse or by pressing a shortcut key. You should always use the command event instead of click because it will be called in all of the needed cases. |
commandupdate |
This event occurs when a command update occurs on a <commandset> element. You would use this to update the disabled status of its commands. |
contextmenu |
This event is sent to an element when the user requests to open the context menu for the element. The action to do this varies by platform, but it will typically be a right click. This handler is usually used to dynamically set the commands on a menu when the user requests to display it, or you can use popupshowing event. Returning false from this event handler prevents the popup from appearing. |
drag |
The drag event is sent to the source node (the node that was dragged) several times a second while the drag is occurring. |
dragdrop |
This event is sent when the user releases the mouse button to drop an object being dragged. The element, if it accepts the drop, should respond in some manner such inserting the dragged object into itself. |
dragend |
The dragend event is sent to the source node (the node that was dragged) when the drag is finished. |
dragenter |
The dragenter event is sent when the mouse pointer first moves over an element during a drag. It is similar to the mouseover event but occurs while dragging. |
dragexit |
This event is sent when the mouse pointer moves away from an element during a drag. It is also called after a drop on an element. It is similar to the mouseout event but occurs during a drag. |
draggesture |
This event is sent when the user starts dragging the element, usually by holding down the mouse button and moving the mouse. |
dragover |
Related to the mousemove event, this event is sent while something is being dragged over an element. The handler should indicate whether the object being dragged can be dropped. |
input |
This event is sent when a user enters text in a textbox. This event is only called when the text displayed would change, thus it is not called when the user presses non-displayable keys. |
overflow |
This event is only sent to a box or other layout element with a CSS overflow property set to a value other than 'visible'. When there is not enough space to display the contents of the element at full size, the overflow event will be fired. Depending on the value of the overflow property, scrollbars may have appeared. For example, if a box has a maximum size of 100 pixels, and only enough space for 80 pixels is available, the overflow event will be sent to the box. If the size changes, for example, by the user resizing the window, the underflow event will be fired when enough space becomes available. |
popuphidden |
This event is sent to a popup after it has been hidden. |
popuphiding |
This event is sent to a popup when it is about to be hidden. |
popupshowing |
This event is sent to a popup just before it is popped open. This handler is usually used to dynamically set the contents when the user requests to display it. Returning false from this event handler prevents the popup from appearing. |
popupshown |
This event is sent to a popup after it has been opened, much like the onload event is sent to a window when it is opened. |
syncfrompreference |
This event is sent when the element is being changed because a preference changed, or when an element is initialized from a preference. This event will only be sent to elements connected to a preference and in a prefwindow. This is not a real event instead it is just a function call and must use the attribute syntax. The script may return a value to set the element to a specific value rather than the value of the preference. This event is usually used to adjust the preference value so that it is more suitable for display in the user interface. |
synctopreference |
This event is sent when the element connected to a preference has changed. This event will only be sent to elements connected to a preference and in a prefwindow. This is not a real event instead it is just a function call and must use the attribute syntax. The script may return a value to set the preference to a specific value rather than the value of the element. |
underflow |
This event is sent to an element when there becomes enough space to display it at full size. This applies to boxes and other layout elements with a CSS overflow property other than 'visible'. The underflow event can be used to indicate that a scrolling mechanism is no longer necessary. |
DOMMenuItemActive |
This event is sent when a menu or menuitem is hovered over, or highlighted. This event bubbles. |
DOMMenuItemInactive |
This event is sent when a menu or menuitem is no longer being hovered over, or highlighted. This event bubbles. |
The following events are dispatched to top-level DOM windows and can be listened to using window.addEventListener.
Event | Description |
---|---|
activate |
Sent when a window becomes active. |
deactivate |
Sent when a window becomes inactive. |
sizemodechange | Sent when a window is minimized or un-minimized, switched between full screen and windowed mode, or maximized. Note: This event may fire several times or while resizing the window (for example, see bug 715867), so always check if the window state changed by inspecting window.windowState in the event. |
These events are used to notify the accessibility system of changes to an element. You would not normally use these yourself.
Event | Description |
---|---|
CheckboxStateChange |
This event is sent when a checkbox is checked or unchecked, either by the user or a script. Normally, you would use the command event to listen to checkbox changes, however, the command event is only sent when the user modifies the value, while the CheckboxStateChange event is also sent when a script modifies the checked property of a checkbox. For user changes, the CheckboxStateChange event is sent before the command event. The CheckboxStateChange event does not bubble. |
RadioStateChange |
This event is sent when a radio button is selected, either by the user or a script. Normally, you would use the command event to listen to radio button selection changes, however, the command event is only sent when the user changes the selected radio button, while the RadioStateChange event is also sent when a script modifies the selection. For user changes, the RadioStateChange event is sent before the command event. The RadioStateChange event bubbles so you can also attach the event handler to the enclosing radiogroup. |