AlfieWebDevTips Homefor new and experienced developers
[Home Home] [Web Development Web Development ] [Code Generators Code Generators ] [Resources Resources ] [Contact Us Contact ] |WebDevTips Privacy Privacy |
Print This Page

You are here : Home - Web Development - Javascript - Getting Started - Events

Events



Events are basically actions, that when performed will execute some javascript code.

You may already be familiar with some javascript events, for example, swapping images on links when the mouse pointer is placed over the link. These are triggered by events. Here are some of the common events :

onload
When used within the <body> tag, this event will trigger once the document has fully loaded. This type of event is the most common event used by popup advertisers.
onmouseover
This event is triggered when the mouse pointer moves over an element on the webpage. The most common use for an onmouseover event is for image swapping on links.
onmouseout
onmouseout is the opposite of onmouseover and is triggered when the mouse pointer moved off of the element. Mainly used to restore an image changed by an onmouseover event
onclick
onclick is triggered by a single mouse click on an element.

Most of the events are normally applied to the the <a> tag. onmouseover and onmouseout when applied to image swapping on links are also called rollovers.

You can apply more than one event to each element as in the following example.

<a href="SOMEURL" onmouseover="DO_SOMETHING" onmouseout="DO_ANOTHER_THING" onclick="DO_SOMETHING ELSE">link text</a>

In plain English, the above line translates to

  • onmouseover="DO_SOMETHING" : when the mouse pointer moves over the "link text" then do something
  • onmouseout="DO_ANOTHER_THING" : when the mouse pointer moves off the "link text" the do another thing
  • onclick="DO_SOMETHING ELSE" : when the mouse button is clicked on the "link text" then do something else.

The DO_SOMETHINGS are known as actions, for example when the event onmouseover occurs what action will be carried out. Actions can be as simple as the Hello World! alert example of they could call a javascript function which we will take a look at next.

That about takes care of events and actions so now we can take a look at functions




16 Nov 2003




Google
 

[back to top of page]   

[labelled with icra -  - this link will open in a new window] [RSS Content]

[Copyright © WebDevTips]