Monday, August 10, 2009

Event/Events Handlers

What are events?



  • The user clicking the mouse button

  • The Web page loading

  • A form field being changed





Events Handlers


To allow you to run your bits of code when these events occur, JavaScript provides us with event handlers.

All the event handlers in JavaScript start with the word on, and each event handler deals with a certain type of event.

Here's a list of all the event handlers in JavaScript, along with the objects they apply to and the events that trigger them:


==
==
==
==
\/























































































































































Event HandlerApplies To:Triggered When:
onAbortImageThe loading of the image is cancelled.
onBlurButton, Checkbox, FileUpload, Layer, Password,

Radio, Reset, Select, Submit, Text, TextArea,

Window
The object in question loses focus

(e.g. by clicking outside it or pressing the TAB key).
onChange FileUpload, Select, Text, TextAreaThe data in the form element is changed by the user.
onClickButton, Document, Checkbox, Link,
Radio, Reset, Submit
The object is clicked on.
onDblClick Document, LinkThe object is double-clicked on.
onDragDrop WindowAn icon is dragged and dropped into the browser.
onError Image, Window A JavaScript error occurs.
onFocus Button, Checkbox, FileUpload, Layer, Password,
Radio, Reset, Select, Submit, Text, TextArea,
Window
The object in question gains focus (e.g.
by clicking on it or pressing the TAB key).
onKeyDown Document, Image, Link, TextAreaThe user presses a key.
onKeyPress Document, Image, Link, TextAreaThe user presses or holds down a key.
onKeyUp Document, Image, Link, TextAreaThe user releases a key.
onLoad Image, WindowThe whole page has finished loading.
onMouseDown Button, Document, LinkThe user presses a mouse button.
onMouseMove NoneThe user moves the mouse.
onMouseOut Image, Link The user moves the mouse away from
the object.
onMouseOver Image, LinkThe user moves the mouse over the
object.
onMouseUp Button, Document, LinkThe user releases a mouse button.
onMove WindowThe user moves the browser window or
frame.
onReset FormThe user clicks the form's Reset button.
onResize WindowThe user resizes the browser window or
frame.
onSelect Text, TextareaThe user selects text within the field.
onSubmit Form The user clicks the form's Submit button.
onUnload WindowThe user leaves the page.

weee

weeee