HTML Elements:Common Events
HTML document elements in Internet Explorer trigger a bewildering plethora of events. In our view it is best to steer clear of browser specific events. The list of events that are available across all three browsers - IE, Firefox and Opera - are discussed below. Where relevant we have indicated browser specific quirks that linger even in standards compliant mode.
- onblur
Typically this event is triggered by controls designed to be placed inside a form - i.e. buttons, textareas, inputs etc - when they loose focus. Passive HTML elements such as paragraphs, spans etc do not respond to this event - logically so, since they do not accept focus for user input in the first place! - onchange
Text controls - input boxes, password inputs and textareas - whose content can change as a result of user input respond to this event. However, the event is only triggered when the control looses focus. This should not normally pose a problem since in order to submit form data the user would click on a button which would cause a previously focused text control to trigger onchange if it has changed. Radio buttons and checkboxes too trigger this event. However, there are a couple of quirks in IE- The event is only triggered when the control looses focus. In Firefox and Opera the event is triggered as soon as the the checked state of the control is altered.
- In IE6 moving focus from one radio button to another one with the same name does not trigger this event.
- onclick
This event is triggered by mouse clicks on most HTML elements - including divisions, paragraphs and spans. - ondblclick
This event behaves as expected in IE and Firefox. However, in Opera the double click only functions with input controls. Others, such as images, divisions etc respond by showing the context menu instead. - onload
Only the script, body and image elements respond to this event. Technically, script is JavaScript DOM object, not an HTML element. - onmousedown, onmousemove & onmouseup
All HTML elements respond to these events. - onreset & onsubmit
Form elements respond to these events. In FireFox the mousemove event is triggered by moves anywhere in the visible area of the document. In IE the event only occurs where the body contains other HTML controls. - onunload
This event occurs just prior to the shutdown of the HTML document currently on display. This can happen in many different ways- The browser is shut down.
- The user navigates to a different URL - either by typing it into the address bar or by selecting it from the history list.
- The browser tab containing the document is closed.
▼Jump To...