[1] Client-side scripting languages like JavaScript, JScript, VBScript, and Java can register various event handlers or listeners on the element nodes inside a DOM tree, such as in HTML, XHTML, XUL, and SVG documents.
To combat this, the event model was standardized by the World Wide Web Consortium (W3C) in DOM Level 2.
Web browsers running on touch-enabled devices, such as Apple's iOS and Google's Android, generate additional events.
For example, web application authors, wishing to intercept a user's intent to undo the last action, need to "listen" for all the following events: It would be simpler to listen for a single, normalized request to "undo" the previous action.
Note that Mozilla, Safari and Opera also support the readystatechange event for the XMLHttpRequest object.
[citation needed] For Mozilla and Opera 9, there are also undocumented events known as DOMContentLoaded and DOMFrameContentLoaded which fire when the DOM content is loaded.
[16] Opera 9 also supports the Web Forms 2.0 events DOMControlValueChanged, invalid, forminput and formchange.
When the user clicks on the inner element, there are two possible ways to handle it: W3C takes a middle position in this struggle.
In the example below, an alert dialog box with the message "Hey Joe" appears after the hyperlink is clicked.
One common misconception[citation needed] with the inline model is the belief that it allows the registration of event handlers with custom arguments, e.g. name in the triggerAlert function.
While it may seem like that is the case in the example above, what is really happening is that the JavaScript engine of the browser creates an anonymous function containing the statements in the onclick attribute.
The onclick handler of the element would be bound to the following anonymous function: This limitation of the JavaScript event model is usually overcome by assigning attributes to the function object of the event handler or by using closures.
To remove an event handler, simply set the property to null: To add parameters: Inner functions preserve their scope.