Intro

The Event Object is the object in Netscape that has information about the event that just occurred. Its syntax is:

event.property
The event object is the object in Microsoft roughly equivalent to the Netscape event object. VBScript must use window.event to distinguish it from the VBScript event keyword. Its syntax is:
window.event.property

Conceptually the two event object do roughly the same things. The type, screenX, and screenY properties are exactly the same in each browser. Two of other properties, x and y, are homonyms. All the other properties are named differently.

Some of the properties only apply to certain events

Event Properties in Alphabetical Order
NN4 IE4 NS6
data
height
layerX
layerY
modifiers
pageX
pageY
screenX
screenY
target
type
which
width
x
y
altKey
button
cancelBubble
clientX
clientY
ctrlKey
fromElement
keyCode
offsetX
offsetY
reason
returnValue
screenX
screenY
shiftKey
srcElement
srcFilter
toElement
type
x
y
 

Position Properties

All position properties return integer values for pixels.

  • screenX and screenY (NN and IE). Relative to the screen.
  • pageX and pageY (NN). clientX and clientY (IE). Relative to the page, i.e. client's window minus tool bars, scroll bars, etc.
  • layerX, layerY, x, and y (NN). Relative to the layer.
  • height and width (NN). Size of the window or frame.
  • offsetX and offsetY (IE). Relative to parent element's 0,0 position.
  • x and y (IE). Returns the position of the mouse hit relative to the element in the parent hierarchy that is positioned using the CSS positioning attribute. If no element in the hierarchy has been positioned, the BODY element is the default.

Mouse over and out.

  • fromElement and toElement (IE). Returns an object for the element being moved from or to in mouseover and mouseout events.

Input Properties

Modifier key

  • modifiers (NN). Returns values for different modifier keys pressed: ALT_MASK, CONTROL_MASK, SHIFT_MASK, and META_MASK.
  • altKey, ctrlKey, shiftKey (IE). Returns true if its corresponding key was pressed.

Key or mouse button

  • which (NN). Returns ASCII decimal value for key pressed or which mouse button was pressed: 1 for left, 2 for middle, and 3 for right.
  • button (IE). Returns integer value for which mouse button was pressed: 0 for none, 1 for left, 2 for right, and 4 for middle.
  • keyCode (IE). Returns Unicode decimal value for key pressed.

Miscellany

Event

  • type (NN and IE). Returns string for the event type, eg CLICK.

Default action

  • returnValue. Read-write property for whether the default action of the source element should occur. False cancels the action. This is equivalent to but take precedence over using a JavaScript return = true; statement (NN).

Event capturing

  • cancelBubble (IE). Read-write property for whether the event should continue bubbling up the DOM hierarchy. The default value is False, i.e. to not cancel bubbling up. See NN4 Events and IE4 Events to see how each browser handles event capturing.

Event generating element

  • target (NN). Returns string representing the object that generated the event.
  • srcElement (IE). Returns an object representing the element that generated the event.

Data

  • data (NN). Returns an array of strings with the URLs of dropped objects. Applies only to the DragDrop event.
  • reason (IE). Returns integer value for disposition of data transfer for a data source object: 0 for successful data transmission, 1 for aborted data transfer, and 2 for error in data transfer.

Dynamic filter

  • srcFilter (IE). Returns the filter object that caused the onfilterchange event to fire.


GeorgeHernandez.comSome rights reserved