Event Handlers Examples

Here are some examples and sample pages of several events.
You should build web pages using the sample code.

1. onunload event handler example

A friendlier use of the onUnload event handler

<body onunload="alert('Thank you. Yah all come back now')">

2 onblur event handler example

Build a page with a User Name textbox.
Write the code that thanks the user when they fill in and exit the textbox.
User Name

<head>
<script type='text/javascript'>
  function taa(){
  if (document.forms[0].elements[0].value !="")
    {alert('Thankyou for your Input');}
  else {alert('the textbox is empty, Try again !');}
}
</script>
</head>

3. Read Only Text Field using Events

A Read only Text box

4. Click the button for an instant pass in this module.

Instant Module Pass

5. Creating a link to go nowhere

By default <a> tags will load another page when clicked. We can create an <a> tag that doesn't load a new page but executes javascript instead.
As we don't want the link itself to work so we must neutralise the href attribute.
<a href='javascript:void(0);' onclick='do this stuff instead' >.

6. An irritatingly friendly form that demonstrates several events

over the top an irritatingly friendly form page demonstrating on blur, onsubmit, onfocus, onreset

7. Using the mouseover event on an image map.

Colour Me mouseovers on an image map.