Sunday, December 2, 2012

What are all the JavaScript events

What is event?

In a simple word, Events are user actions. For example when a user click a button in a webpage that should trigger some actions that perform some function execution. The following is the JavaScript events and when its occurs.

JavaScript Events

onabort       : This event occurs  when the user aborts an action
onblur        : This event occurs  when an element loses the input focus
onchange      : This event occurs  when data in a control, such as a text field changes
onclick       : This event occurs  when the user clicks an element
ondblclick    : This event occurs  when the user double-clicks an element
onkeyup       : This event occurs  when the user releases a key
onload        : This event occurs  when the page loads
onmousedown   : This event occurs  when the user presses down a mouse button
onmousemove   : This event occurs  when the user moves the mouse
onmouseout    : This event occurs  when the user moves the cursor away from an element
onmouseover   : This event occurs  when the user moves the cursor over an element
ondragdrop    : This event occurs  when the user drags and drops an element
onerror       : This event occurs  when there’s been a JavaScript error
onfocus       : This event occurs  when an element gets the focus
onkeydown     : This event occurs  when the user presses down on a key
onkeypress    : This event occurs  when the user presses a key
onmouseup     : This event occurs  when the user releases a mouse button
onreset       : This event occurs  when the user clicks a Reset button
onresize      : This event occurs  when the user re sizes an element or a page
onsubmit      : This event occurs  when the user clicks a Submit button
onunload      : This event occurs  when the browser unloads a page and moves to another page

Example:


 <html>  
 <head>  
 <script>  
    function displayText()  
    {  
      alert('Hi User');  
    }  
 </script>  
 </head>  
 <body>  
 <h1 onclick="displayText()">Click on this text!</h1>  
 </body>  
 </html>  

No comments:

Post a Comment