Print
12
May
2008

JavaScript Events Overview

Events are actions that can be detected by JavaScript. Every element on a web page has certain events which can trigger JavaScript functions.

For example, we can use the onClick event of a button element to indicate that a function will run when a user clicks on the button. We define the events in the HTML tags.

JavaScript Events

JavaScript events include:

Event Occurs when:
onabort Loading of an image is interrupted
onblur An element loses focus
onchange The user changes the content of a field
onclick Mouse clicks an object
ondblclick Mouse double-clicks an object
onerror An error occurs when loading a document or an image
onfocus An element gets focus
onkeydown A keyboard key is pressed
onkeypress A keyboard key is pressed or held down
onkeyup A keyboard key is released
onload A page or an image is finished loading
onmousedown A mouse button is pressed
onmousemove The mouse is moved
onmouseout The mouse is moved off an element
onmouseover The mouse is moved over an element
onmouseup A mouse button is released
onreset The reset button is clicked
onresize A window or frame is resized
onselect Text is selected
onsubmit The submit button is clicked
onunload The user exits the page

 

JavaScripts within HTML Tags

JavaScript Events are associated with HTML Tags.

The events for each HTML tag are:

HTML Tag Events
<a>onClick
onMouseOver
onMouseOut
<area>

onMouseOver
onMouseOut

<body>onBlur
onError
onFocus
lonLoad
onUnload
<form>onSubmit
onReset
<frame>onBlur
onFocus
<frameset>onBlur
onError
onFocus
onLoad
onUnload
<img>onAbort
onError
onLoad
<INPUT TYPE = "button">
<INPUT TYPE = "checkbox">
<INPUT TYPE = "reset">
<INPUT TYPE = "submit">
onClick
<INPUT TYPE = "text">onBlur
onFocus
onChange
onSelect
<SELECT>onBlur
onFocus
onChange
<TEXTAREA>onBlur
onFocus
onChange
onSelect)

 

To handle an event within HTML:

onEvent = "Code to handle the event"

 

Examples:

<input type="text" size="30" id="email" onchange="checkEmail()">;

 

 

 

Interested in building next-gen Big Data architecture? Join our webcast on 5/24 at 9am PT. Register here: http://t.co/k5Dsfskg

Oracle Oracle

#Oracle User Groups: Are You a Member Yet? Learn more about our 870 User Groups worldwide and become a member today: http://t.co/LsktPjH5

Oracle Oracle