event
Theevent object contains properties that describe a JavaScript event, and is passed as an argument to an event handler when the event occurs.event object contains the type of event (in this case MouseDown), the x and y position of the cursor at the time of the event, a number representing the mouse button used, and a field containing the modifier keys (Control, Alt, Meta, or Shift) that were depressed at the time of the event. The properties used within the event object vary from one type of event to another. This variation is provided in the descriptions of individual event handlers.
See Chapter 3, "Event Handlers," for complete information about event handlers. For more information on handling events, see the Client-Side JavaScript Guide.
Created by
event objects are created by Communicator when an event occurs. You do not create them yourself.
Security
Setting any property of this object requires theUniversalBrowserWrite privilege. In addition, getting the data property of the DragDrop event requires the UniversalBrowserRead privilege. For information on security, see the Client-Side JavaScript Guide.
Property Summary
Not all of these properties are relevant to each event type. To learn which properties are used by an event, see the "Event object properties used" section of the individual event handler.
Method Summary
This object inherits thewatch and unwatch methods from Object.
Examples
The following example uses the event object to provide the type of event to the alert message.<A HREF="http://home.netscape.com" onClick='alert("Link got an event: "The following example uses the event object in an explicitly called event handler.
+ event.type)'>Click for link event</A>
<SCRIPT>
function fun1(evnt) {
alert ("Document got an event: " + evnt.type);
alert ("x position is " + evnt.layerX);
alert ("y position is " + evnt.layerY);
if (evnt.modifiers & Event.ALT_MASK)
alert ("Alt key was down for event.");
return true;
}
document.onmousedown = fun1;
</SCRIPT>
data
For the DragDrop event, returns an array of strings containing the URLs of the dropped objects.Security
Setting this property requires theUniversalBrowserWrite privilege. In addition, getting this property for the DragDrop event requires the UniversalBrowserRead privilege. For information on security, see the Client-Side JavaScript Guide.
height
Represents the height of the window or frame.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.width
layerX
Number specifying either the object width when passed with the resize event, or the cursor's horizontal position in pixels relative to the layer in which the event occurred.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
Description
This property is synonymous with theevent.x property.
See also
event.layerY
layerY
Number specifying either the object height when passed with the resize event, or the cursor's vertical position in pixels relative to the layer in which the event occurred.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
Description
This property is synonymous with theevent.y property.
See also
event.layerX
modifiers
String specifying the modifier keys associated with a mouse or key event. Modifier key values are: ALT_MASK, CONTROL_MASK, SHIFT_MASK, and META_MASK.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.which
pageX
Number specifying the cursor's horizontal position in pixels, relative to the page.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.pageY
pageY
Number specifying the cursor's vertical position in pixels relative to the page.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.pageX
screenX
Number specifying the cursor's horizontal position in pixels, relative to the screen.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.screenY
screenY
Number specifying the cursor's vertical position in pixels, relative to the screen.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.screenX
target
String representing the object to which the event was originally sent.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.type
type
String representing the event type.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.target
which
Number specifying either the mouse button that was pressed or the ASCII value of a pressed key. For a mouse, 1 is the left button, 2 is the middle button, and 3 is the right button.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.modifiers
width
Represents the width of the window or frame.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
event.height
x
Number specifying either the object width when passed with the resize event, or the cursor's horizontal position in pixels relative to the layer in which the event occurred.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
Description
This property is synonymous with theevent.layerX property.
See also
event.y
y
Synonym forlayerY.Security
Setting this property requires theUniversalBrowserWrite privilege. For information on security, see the Client-Side JavaScript Guide.
Description
This property is synonymous with theevent.layerY property.
See also
event.x
Table of Contents | Previous | Next | Index
Last Updated: 05/28/99 11:59:24
