Translate

Monday, 23 April 2012

JavaScript Events


What is a Javascript Event?

An event is an action or a happening that browser can detect. For example a button placed on a webpage is clicked, some text is selected, pressing a keyboard button, mouse pointer is moved over to a picture. Whenever these and such other actions occur, Javascript code in the browser is able to detect the event and thus the proceeding action can be programmed- i.e. javascript programmer can tell the browser about what to do when a certain event occurs.
Generally events refer to some action by the user/visitor of the webpage however loading of a picture on a webpage or loading of a new webpage are also happenings that browsers recognize as events.
The actions to proceed the event are usually coded in the form of functions(will study them later in this course). A simple intro to a function is that it is a block of code lines that perform a specific task/function. A single function can be used on many pages throughout the site.

JS Events and Browser Compatibility issues


List of JavaScript Events

There are many types of javascript events. We will cover most of them in this course.
  1. JavaScript Mouse Events
    • OnMouseOver
    • OnMouseOut
    • OnMouseMove
    • OnMouseup
    • OnMousedown
  2. JavaScript Mouse Click Events
    • Onclick
    • Ondblclick
    • Oncontextmenu - (right click)
  3. JavaScript Keyboard Events
    • OnKeydown
    • OnKeypress
    • OnKeyup
  4. Form and Field Events
    • OnClick
    • OnSelect
    • OnSubmit
    • OnBlur
    • OnFocus
    • OnChange
    • OnReset
  5. Window Events
    • OnError- When an error occurs in loading of page or elements within it.
    • Onload- When a page is loaded
    • OnUnload- When a user leaves or closes a page
    • OnAbort
    • OnBlur
    • OnScroll
    • OnFocus
    • OnMove
    • OnResize
We will look at examples of each one of the frequently used events mentioned above in the coming lessons.
IMPORTANT NOTE: We have mentioned all the events generally used. However if you are a beginner, you might find all this information on JS events overwhelming. In that case, you can study only the most generally used events.

List of Most Frequently used JS Events

  • Onsubmit
  • Onclick
  • OnMouseOver

No comments: