JAVA Tech VERSION 3.0 manual Event Handler and Event Handling

Models: VERSION 3.0

1 88
Download 88 pages 5.41 Kb
Page 82
Image 82

The Event Handler and Event Handling

ViewONE introduces the concept of applet JavaScript event handling. This is a mechanism by which it is possible to use JavaScript to monitor user activity and other selected actions performed by the ViewONE applet.

This can be a powerful facility, for example, it allows user activity and usage to be logged and/or actions to be performed dependent on what the user is doing/has done (e.g. charge for specific services like printing, perform actions on double-clicks, monitor documents opened etc).

The event handling is first enabled by the use of the HTML tag “eventHandler” and the MayScript tag (see example below). The eventHandler tag must be set to the name of a JavaScript function conforming to the following specification.

When the applet is initialized, it will call this function, passing it parameters relevant to the action performed as described below.

The JavaScript ‘event handler’ must be specified with two parameters; id (integer) and text (String), but can be any name of your choice, as follows…

Function myEventHandler(id, text)

{

alert(“Event received, id=“+id+”, text=“+text);

}

In this example, the event handler just displays a notice to the user that an event had been received. You are however free to do whatever you need, for example testing the value of the id and text fields then taking further actions as necessary.

82

Page 82
Image 82
JAVA Tech VERSION 3.0 manual Event Handler and Event Handling