An Event object is created automatically by JavaScript on the occurance of an event. It has various properties that provide information about the event such as event type, the position of the cursor at the time the event occured, etc. Not all of the properties relate to every type of event; the one's that do are documented in the individual event handler pages.
<input type="button" value="Event type" onClick='alert("The
event type is " + event.type)'>
This example creates a button that, when clicked, displays an alert box showing the event type (in this case a 'click' event).
Syntax: Object.constructor
This specifies a function to create an object's property and is inherited by all objects from their prototype.
Syntax: event.data
This property relates to the DragDrop event and its use returns an array that contains the URLs of any dropped objects, as strings.
Syntax: event.height
This property relates to the height of the window or frame that contains the object that initiated the event.
Syntax: event.keyCode
Contains the last key that was pressed.
Syntax: event.layerX
These properties returns a number that represents the horizontal/vertical position, in pixels, of the cursor relative to the layer that initiated the event, or, when passed with a resize event, it represents the object width/height. These properties are synonyms for, and interchangable with, the x and y event object properties.
Syntax: event.layerY
These properties returns a number that represents the horizontal/vertical position, in pixels, of the cursor relative to the layer that initiated the event, or, when passed with a resize event, it represents the object width/height. These properties are synonyms for, and interchangable with, the x and y event object properties.
Syntax: event.modifiers
This property returns a string containing details of any modifier keys that were held down during a key or mouse event. The values of the modifier keys are as follows: ALT_MASK, CONTROL_MASK, SHIFT_MASK and META_MASK.
Syntax: event.pageX
These properties return the horizontal/vertical position of the cursor relative to the page, in pixels, at the time the event occured.
Syntax: event.pageY
These properties return the horizontal/vertical position of the cursor relative to the page, in pixels, at the time the event occured.
Syntax: Object.prototype.name = value
This allows the addition of properties and methods to any object.
Syntax: event.screenX
These properties return the horizontal/vertical position of the cursor relative to the screen, in pixels, at the time the event occured.
Syntax: event.srcElement[ = oObject ]
Sets of retrieves te object that fired the event.
Syntax: event.target
This property returns a reference to the object that the event was originally sent to.
Syntax: event.type
This property returns a string that represents the type of the event (click, key down, etc.).
Syntax: event.which
This property returns a number that represents either which mouse button (1 being the left button, 2 the middle and 3 the right) was pressed or which key was pressed (its ASCII value) at the time the event occuered.
Syntax: event.width
This property relates to the height of the window or frame that contains the object that initiated the event.
Syntax: event.x
These properties returns a number that represents the horizontal/vertical position, in pixels, of the cursor relative to the layer that initiated the event, or, when passed with a resize event, it represents the object width/height. These properties are synonyms for, and interchangable with, the layerX and layerY event object properties.
Syntax: event.y
These properties returns a number that represents the horizontal/vertical position, in pixels, of the cursor relative to the layer that initiated the event, or, when passed with a resize event, it represents the object width/height. These properties are synonyms for, and interchangable with, the layerX and layerY event object properties.
Syntax: Object.eval(string)
The eval method is deprecated as a method of Object, but is still used as a high level function. It evaluates a string of JavaScript in the context of an object.
Syntax: Object.toSource()
The toSource method returns a literal representing the source code of an object. This can then be used to create a new object.
Syntax: Object.toString()
The toString method returns a string representing a specified object.
Syntax: Object.unwatch(property)
This method removes a watchpoint set for an object and property name with the watch method.
Syntax: Object.valueOf()
This method returns a primitive value for a specified object.
Syntax: Object.watch(property, handlerfunction)
This method adds a watchpoint to a property of the object.