This is part of the event management suite which allow events to be routed to handlers other than just the one that defaults to being associated with an event.
The events to be captured are signified by setting bits in a mask.
This method allows you to specify what events are to be routed to the receiving Document object.
The events are specified by using the bitwise OR operator to combine the required event mask constants into a mask that defines the events you want to capture. Refer to the Event Type Constants topic for a list of the event mask values.
A limitation of this technique is that ultimately, only 32 different kinds of events can be combined in this way and this may limit the number of events the browser can support. Since this is only supported by Netscape, the functionality is likely to be deprecated when the standards bodies agree on a standard way of handling events. Then we simply need to wait for the browser manufacturers to support the standardized behavior.
In the meantime, we shall have to implement scripts using this capability if we need to build complex event handling systems. A different script will be required for MSIE.
You may be able to factor your event handler so that you only have to make platform specific event dispatchers and can call common handling routines that can be shared between MSIE and Netscape .
The example copes with cross browser execution in an interesting way.
Since a bit mask is being used, this must be an int32 value. This suggests that there can only be 32 different Event types supported by this event propagation model.
This capability is deprecated and is not supported in Netscape 6.0 anymore. It never was supported by MSIE which implements a completely different event model. As it turns out the DOM level 2 event model converges on the MSIE technique.
// A portable keyboard event handler // Provided by Jon Stephens function handleKeypress(event) { var key; if(document.layers) { key = event.which; } if(document.all) { event = window.event; key = event.keyCode; } alert("Key: " + String.fromCharCode(key) + "\nCharacter code: " + key + "."); } if(document.layers) { document.captureEvents(Event.KEYPRESS); } document.onkeypress = handleKeypress;
Prev | Home | Next |
Document.body | Up | Document.characterset |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |