document.formName.onsubmit = 'function onsubmit(event) { alert("Changed"); }' ;
The complete list of Event Handlers:
- onAbort - The user aborts the loading of an image
- onBlur - form element loses focus or when a window or frame loses focus.
- onChange - select, text, or textarea field loses focus and its value has been modified.
- onClick - object on a form is clicked.
- onDblClick - user double-clicks a form element or a link.
- onDragDrop - user drops an object (e.g. file) onto the browser window.
- onError - loading of a document or image causes an error.
- onFocus - window, frame, frameset or form element receives focus.
- onKeyDown - user depresses a key.
- onKeyPress - user presses or holds down a key.
- onKeyUp - user releases a key.
- onLoad - browser finishes loading a window or all of the frames within a frameset.
- onMouseDown - user depresses a mouse button.
- onMouseMove - user moves the cursor.
- onMouseOut - cursor leaves an area or link.
- onMouseOver - cursor moves over an object or area.
- onMouseUp - user releases a mouse button.
- onMove - user or script moves a window or frame.
- onReset - user resets a form.
- onResize - user or script resizes a window or frame.
- onSelect - user selects some of the text within a text or textarea field.
- onSubmit - user submits a form.
- onUnload - user exits a document.
JavaScript 1.0
JavaScript 1.0 is supported by Netscape Navigator 2.0 and partially by Microsoft Internet Explorer 3.0.
Object | Event Handlers |
button | onBlur()1, onClick(), onFocus()1 |
checkbox | onBlur()1, onClick(), onFocus()1 |
fileupload | onBlur(), onChange()2, onFocus() |
form | onSubmit() |
link | onClick(), onMouseOver() |
password | onBlur(), onChange()3, onFocus() |
radio | onBlur()1, onClick(), onFocus()1 |
reset | onBlur()1, onClick()4, onFocus()1 |
select | onBlur()1, onChange()5, onFocus()1 |
submit | onBlur()1, onClick()6, onFocus()1 |
text | onBlur(), onChange(), onFocus() |
textarea | onBlur(), onChange(), onFocus() |
window | onLoad(), onUnload() |
1 In Navigator 2.0 for Unix platforms, the onBlur() and onFocus() event handlers are only invoked
for the text entry elements: text, textarea, password and fileupload.
2 In Navigator 2.0 the fileupload input is hidden from JavaScript, so onChange() is limited.
3 In Navigator 2.0 the password input is hidden from JavaScript, so onChange() is limited.
4 In Navigator 2.0 the reset onClick() event handler cannot cancel the form being reset.
5 In Navigator 2.0 for Windows platforms, the onChange() event handler is not invoked
immediately after a select option is chosen.
6 In Navigator 2.0 the submit onClick() event handler cannot cancel the form submission.
JavaScript 1.1
JavaScript 1.1 is supported by Netscape Navigator 3.0 and partially by Microsoft Internet Explorer 3.0.
Object | Event Handlers |
area | onClick()2, onMouseOut(), onMouseOver() |
button | onBlur()1, onClick(), onFocus()1 |
checkbox | onBlur()1, onClick(), onFocus()1 |
fileupload | onBlur(), onChange(), onFocus() |
form | onReset(), onSubmit() |
frame | onLoad(), onUnload() |
image3 | onAbort()3, onError()3, onLoad()3 |
link | onClick()2, onMouseOut(), onMouseOver() |
password | onBlur(), onChange(), onFocus() |
radio | onBlur()1, onClick(), onFocus()1 |
reset | onBlur()1, onClick(), onFocus()1 |
select | onBlur()1, onChange(), onFocus()1 |
submit | onBlur()1, onClick(), onFocus()1 |
text | onBlur(), onChange(), onFocus() |
textarea | onBlur(), onChange(), onFocus() |
window | onBlur()4, onError()4, onFocus()4, onLoad(), onUnload() |
1 In Navigator 3.0 for Unix platforms, the onBlur() and onFocus() event handlers are only
invoked for the text entry elements: text, textarea, password and fileupload.
2 In Navigator 3.0 for Windows platforms, the onClick() event handler is not supported by the
area object.
3 In Explorer 3.0 the image object is not supported.
4 In Explorer 3.0 the window objects onBlur(), onError() and onFocus() event handlers are not
supported.
JavaScript 1.2
JavaScript 1.2 is supported by Netscape Navigator 4.0. Although Microsoft Internet Explorer appears to
support JavaScript 1.2, it actually implements a different Dynamic Object Model which will not be descibed
here.
Object | Event Handlers |
area | onDblClick(), onMouseOut(), onMouseOver() |
button | onBlur(), onClick(), onFocus(), onMousedown(), onMouseup() |
checkbox | onBlur(), onClick(), onFocus() |
document | onClick(), onDblClick(), onKeyDown(), onKeyPress(), onKeyUp(), onMouseDown(), onMouseUp() |
fileupload | onBlur(), onChange(), onFocus() |
form | onReset(), onSubmit() |
frame | onBlur(), onDragDrop(), onError(), onFocus(), onLoad(), onMove(), onResize(), onUnload() |
image | onAbort(), onError(), onKeyDown(), onKeyPress(), onKeyUp(), onLoad() |
layer | onMouseOver(), onMouseOut(), onLoad(), onFocus(), onBlur() |
link | onClick(), onDblClick(), onKeyDown(), onKeyPress(), onKeyUp(), onMouseDown(), onMouseOut(), onMouseUp(), onMouseOver() |
password | onBlur(), onFocus() |
radio | onBlur(), onClick(), onFocus() |
reset | onBlur(), onClick(), onFocus() |
select | onBlur(), onChange(), onFocus() |
submit | onBlur(), onClick(), onFocus() |
text | onBlur(), onChange(), onFocus(), onSelect() |
textarea | onBlur(), onChange(), onFocus(), onKeyDown(), onKeyPress(), onKeyUp(), onSelect() |
window | onBlur(), onDragDrop(), onError(), onFocus(), onLoad(), onMove(), onResize() onUnload() |
Summary
As you can see there is only a small subset of Event Handlers (i.e. JavaScript 1.0) that is supported by
all JavaScript enabled browsers. And amongst those there are bugs and or unsupported features. Knowing
these 'features' makes the difference between a casual JavaScript programmer and an expert.
To find out more information on JavaScript Event Handlers read the online JavaScript documentation:
Netscape Navigator 4.0 - http://developer.netscape.com/library/documentation/communicator/jsref/index.htm
Microsoft Internet Explorer 4.0 - http://www.microsoft.com/JScript/us/techinfo/jsdocs.htm
Related itemsMan-Handling Events #3 Man-Handling Events #2 Man-Handling Events #1
Feedback on 'Events and Event Handlers'©2018 Martin Webb
|