Availability: |
| ||||||
JavaScript syntax: | - | myEvent = event | |||||
- | myEvent = myWindow.event | ||||||
N | myEvent = myDocumentEvent.createEvent(aType) | ||||||
Argument list: | aType | An event type | |||||
Object properties: | altKey, bubbles, button, cancelable, cancelBubble, charCode, clientX, clientY, ctrlKey, currentTarget, data, dataFld, dataTransfer, eventPhase, fromElement, height, keyCode, layerX, layerY, modifiers, offsetX, offsetY, pageX, pageY, propertyName, qualifier, reason, recordset, repeat, returnValue, screenX, screenY, shiftKey, srcElement, srcFilter, srcUrn, target, timeStamp, toElement, type, which, width, x, y | ||||||
Class constants: | ABORT, ALT_MASK, AT_TARGET, BACK, BLUR, BUBBLING_PHASE, CAPTURING_PHASE, CHANGE, CLICK, CONTROL_MASK, DBLCLICK, DRAGDROP, ERROR, FOCUS, FORWARD, HELP, KEYDOWN, KEYPRESS, KEYUP, LOAD, LOCATE, META_MASK, MOUSEDOWN, MOUSEDRAG, MOUSEMOVE, MOUSEOUT, MOUSEOVER, MOUSEUP, MOVE, RESET, RESIZE, SCROLL, SELECT, SHIFT_MASK, SUBMIT, UNLOAD, XFER_DONE | ||||||
Object methods: | initEvent(), preventDefault(), stopPropagation() | ||||||
Collections: | bookmarks[], boundElements[] |
The event models in Netscape version 4 and MSIE version 4 support an Event object. However, both browsers support different properties for this object. It may be possible with some smart JavaScript code to normalize these to look like the same object model. You could either define your own or take one and emulate it in the other.
As well as being different, the Event object is passed to event handlers in a different way for each browser. Netscape version 4 passes the Event object as an argument. MSIE version 4 stores a reference to it in the global variable called event.
Netscape provides a set of static constants that can be used to manufacture modifier masks. These can then be tested against the Event.modifiers property. These constants have names that all end with the suffix "_MASK". There are other constants provided so masks for event types can be made. These can be tested against the Event.type property.
MSIE does not support these static constants in the same way and uses fully spelled-out event names as string primitive values for matching. This ultimately may be better because Netscape is constrained for space as regards bit values for new events. There are only 32 bits and most have already been allocated to event types.
As of version 6.0 of Netscape, the underlying event model is based on the DOM level 2 event module. This is fundamentally different to the support of events in earlier versions of the Netscape browser. DOM level 2 and Netscape 6.0 converge on the same basic model as MSIE. This adds some new properties, methods and static constants in accordance with the DOM specification. Some properties persist from earlier versions.
The DOM level 2 specification for events describes a category of HTMLEvents which it suggests is based on DOM level 0 capabilities. There is only a small amount of information about the event type strings and the event capabilities in the DOM level 2 context. No ECMAScript binding is described and because DOM level 0 has never been published as a standard, there is a little ambiguity about these events. The standardization is somewhat de-facto regarding them and in due course, as the DOM event model evolves, this should all become more consistent and more completely documented.
Properties belonging to an Event object cannot be set in Netscape unless the script has the UniversalBrowserWrite privilege. You also cannot watch events in other windows if they are loaded from different sources unless the script also has the UniversalBrowserWrite privilege.
The properties and methods supported by Netscape and MSIE differ greatly in name and function. You will need to be very careful when building sophisticated event management capabilities into your scripts.
Netscape does not implement all of the events for which there are static constants defined.
// List the event constants in Netscape. // This does not work in MSIE. d = document; e = Event; s1 = "<TR><TD>"; s2 = "</TD><TD>"; s3 = "</TD></TR>"; d.write("<TABLE BORDER=1>"); d.write(s1 + "MOUSEDOWN" + s2 + e.MOUSEDOWN + s3); d.write(s1 + "MOUSEUP" + s2 + e.MOUSEUP + s3); d.write(s1 + "MOUSEOVER" + s2 + e.MOUSEOVER + s3); d.write(s1 + "MOUSEOUT" + s2 + e.MOUSEOUT + s3); d.write(s1 + "MOUSEMOVE" + s2 + e.MOUSEMOVE + s3); d.write(s1 + "CLICK" + s2 + e.CLICK + s3); d.write(s1 + "DBLCLICK" + s2 + e.DBLCLICK + s3); d.write(s1 + "KEYDOWN" + s2 + e.KEYDOWN + s3); d.write(s1 + "KEYUP" + s2 + e.KEYUP + s3); d.write(s1 + "KEYPRESS" + s2 + e.KEYPRESS + s3); d.write(s1 + "DRAGDROP" + s2 + e.DRAGDROP + s3); d.write(s1 + "FOCUS" + s2 + e.FOCUS + s3); d.write(s1 + "BLUR" + s2 + e.BLUR + s3); d.write(s1 + "SELECT" + s2 + e.SELECT + s3); d.write(s1 + "CHANGE" + s2 + e.CHANGE + s3); d.write(s1 + "RESET" + s2 + e.RESET + s3); d.write(s1 + "SUBMIT" + s2 + e.SUBMIT + s3); d.write(s1 + "LOAD" + s2 + e.LOAD + s3); d.write(s1 + "UNLOAD" + s2 + e.UNLOAD + s3); d.write(s1 + "ABORT" + s2 + e.ABORT + s3); d.write(s1 + "ERROR" + s2 + e.ERROR + s3); d.write(s1 + "MOVE" + s2 + e.MOVE + s3); d.write(s1 + "RESIZE" + s2 + e.RESIZE + s3); d.write("</TABLE>");
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
altKey | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
bubbles | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly |
button | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
cancelable | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly |
cancelBubble | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
charCode | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
clientX | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
clientY | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
ctrlKey | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
currentTarget | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly |
data | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
dataFld | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
dataTransfer | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
eventPhase | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly |
fromElement | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
height | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
keyCode | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
layerX | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
layerY | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
modifiers | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
offsetX | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
offsetY | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
pageX | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
pageY | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
propertyName | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
qualifier | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
reason | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
recordset | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
repeat | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
returnValue | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
screenX | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
screenY | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
shiftKey | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
srcElement | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
srcFilter | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
srcUrn | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
target | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly |
timeStamp | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
toElement | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
type | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly |
which | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
width | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
x | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
y | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly |
Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
initEvent() | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | - |
preventDefault() | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | - |
stopPropagation() | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | - |
Prev | Home | Next |
Event names | Up | Event.altKey |
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. |