Click to skip over navigation
 

lecture 8: other events

<< previous slide

return to lesson 8 index

next slide >>


onmouseover and onmouseout are called event handlers. They have the appearance of attributes, in that they go inside tags, can appear in any order, have a similar syntax and do not appear in the closing tag. But they are not actually HTML.

There are quite a few other event handlers. The next most common is probably onclick. This event appears in each of the links on the right and, well, you can see the result. Once again I'm using it to roll over an image: subsequent slides will suggest other applications of JavaScript events.

onclick can also be coded into form buttons, although we haven't discovered how to create them yet. They'll appear in the next lecture. Some of the other event handlers given below also work best with form elements and are worth remembering for next week.

Q: Who won the 2004 European Football Championship?

Portugal

Czech Republic

Greece

Here are some other event handlers. This is not the full list, although these are the most common ones:

  • onselect: causes something to happen when a form element or link is selected either via the mouse or by using the tab key.
  • onload: causes something to happen when the page loads. Code it into the <body> tag. This is how sites get "pop-up windows" to appear when you visit the page - usually used for advertising although you will, of course, apply it to some less irritating end (won't you)?
  • onunload: potentially even more irritating - causes something to happen when the page is left. (Really - don't abuse this one. If people want to leave your page, let them. It's still nominally a free country.)
  • onsubmit: causes something to happen when a form is submitted.
  • onchange: causes something to happen when a form element is changed, e.g. the user selects something from a drop-down menu.

Read on for some more ideas as to what you can actually do with these events.




<< previous slide

return to lesson 8 index

next slide >>