View Tutorial Metadata Edit Content Revision History Add to Watchlist Add New Tutorial Event handling in JavaScript

Event handling in JavaScript

The Observer pattern in JavaScript

This is a discussion on Event Handling (or Observer pattern) in JavaScript, in which we describe what it's useful for and how it's done in various frameworks.

Prerequisites

You should have a general understanding of Events and Handlers in Computing . Before you read this, you should also be familiar with the JavaScript Language .

How events occur in JavaScript

A document in a browser is interactive: it contains elements such as links and buttons that can be pressed, it is sensitive to mouse movements and key presses.

For example, you may have a link that, when clicked, should show a image. Event handling allows you to script web pages so that a piece of code is executed whenever a certain action is performed.

Unfortunately each browser has its own somewhat particular implementation of this functionality. However, since this functionality is similar across browser, it's possible to create pieces of code that act consistently on different platforms.

Events in JavaScript Frameworks

JavaScript frameworks allow you to write code which interprets events in a fashion that is, at least ideally, browser-independent.

Only plain text supported.

Optional

Required - will be kept private

Optional

 
 

Rating: (0+, 0-) In: JavaScript