Javascript [Electronic resources] : The Definitive Guide (4th Edition) نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Javascript [Electronic resources] : The Definitive Guide (4th Edition) - نسخه متنی

David Flanagan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید

Availability


JavaScript 1.2; incompatible versions supported by Netscape 4 and IE 4


Synopsis

function handler(event) { ... } // Event handler argument in Netscape 4
window.event // Window property in IE 4

Constants


In
Netscape 4,
the Event object defines bitmask constants for each of the supported
event types. These static properties are used to form the bitmasks
that are passed to captureEvents( ) and
releaseEvents( ). The available constants are:









































Event.ABORT

Event.BLUR

Event.CHANGE

Event.CLICK

Event.DBLCLICK

Event.DRAGDROP

Event.ERROR

Event.FOCUS

Event.KEYDOWN

Event.KEYPRESS

Event.KEYUP

Event.LOAD

Event.MOUSEDOWN

Event.MOUSEMOVE

Event.MOUSEOUT

Event.MOUSEOVER

Event.MOUSEUP

Event.MOVE

Event.RESET

Event.RESIZE

Event.SELECT

Event.SUBMIT

Event.UNLOAD


Netscape 4 Properties


height

Set
only in events of type "resize". Specifies the new height
of the window or frame that was resized.

layerX, layerY

Specify the X- and Y-coordinates, relative to the enclosing layer, at
which an event occurred.

modifiers

Specifies which keyboard modifier keys were held down
when the event occurred. This numeric value is a bitmask consisting
of any of the constants Event.ALT_MASK,
Event.CONTROL_MASK,
Event.META_MASK, or
Event.SHIFT_MASK. Due to a bug, this property is
not defined in Netscape 6 or 6.1.

pageX, pageY

Specify the X- and Y-coordinates, relative to the web browser page,
at which the event occurred. Note that these coordinates are relative
to the top-level page, not to any enclosing layers.

screenX, screenY

Specify the X- and Y-coordinates, relative to the screen, at which
the event occurred. Note that, unlike most Event properties, these
properties are supported by and have the same meaning in both
Netscape 4 and Internet Explorer 4.

target

Specifies the Window, Document, Layer, or HTMLElement object on which
the event occurred.

type

A string property that specifies the type of the event. Its value is
the name of the event handler minus the "on" prefix. So
when the onclick( ) event handler is invoked, the
type property of the Event object is
"click".

which

For keyboard and mouse events, which specifies
which key or mouse button was pressed or released. For keyboard
events, this property contains the character encoding of the key that
was pressed. For mouse events, it contains 1, 2, or 3, indicating the
left, middle, or right buttons.

width

Set only in events of type "resize". Specifies the new
width of the window or frame that was resized.

x, y

Specify the X- and Y-coordinates at which the event occurred. In
Netscape 4, these properties are synonyms for
layerX and layerY and specify
the position relative to the containing layer (if any). Their meaning
is different in Internet Explorer (see below).


Internet Explorer 4 Properties


altKey

A boolean value that specifies whether the

Alt key was held down when the event occurred.

button

For mouse events, button specifies which mouse
button or buttons were pressed. This read-only integer is a bitmask:
the 1 bit is set if the left button was pressed; the 2 bit is set if
the right button was pressed; and the 4 bit is set if the middle
button (of a three-button mouse) was pressed.

cancelBubble

If an event handler wants to stop an event from being propagated up
to containing objects, it must set this property to
true.

clientX, clientY

Specify the X- and Y-coordinates, relative to the web browser page,
at which the event occurred.

ctrlKey

A boolean value that specifies whether the

Ctrl key was held down when the event
occurred.

fromElement

For mouseover and mouseout events, fromElement
refers to the object from which the mouse pointer is moving.

keyCode

For keyboard events, keyCode specifies the Unicode
character code generated by the key that was struck.

offsetX, offsetY

Specify the X- and Y-coordinates at which the event occurred within
the coordinate system of the event's source element (see
srcElement).

reason

For the datasetcomplete event,
reason contains a code that specifies the status
of the data transfer. A value of 0 indicates a successful transfer. A
value of 1 indicates that the transfer was aborted. A value of 2
indicates that an error occurred during data transfer.

returnValue

If this property is set, its value takes precedence over the value
actually returned by an event handler. Set this property to
false to cancel the default action of the source
element on which the event occurred.

screenX, screenY

Specify the X- and Y-coordinates, relative to the screen, at which
the event occurred. Note that, unlike most Event properties, these
two properties are supported by and have the same meaning in both
Netscape 4 and Internet Explorer 4.

shiftKey

A boolean value that specifies whether the

Shift key was held down when the event
occurred.

srcElement

A reference to the Window, Document, or HTMLElement object that
generated the event.

srcFilter

For filterchange events, srcFilter specifies the
filter that changed.

toElement

For mouseover and mouseout events, toElement
refers to the object into which the mouse pointer is moving.

type

A string property that specifies the type of the event. Its value is
the name of the event handler minus the "on" prefix. So
when the onclick( ) event handler is invoked, the
type property of the Event object is
"click".

x, y

Specify the X- and Y-coordinates at which the event occurred. In
Internet Explorer 4, this property specifies the X position relative
to the innermost containing element that is dynamically positioned
using CSS. The interpretation of these properties is different in
Netscape 4 (see the previous section).


Description


The Event object provides details about an event that has occurred.
Unfortunately, these details are not standardized, and Netscape 4 and
IE 4 define Event objects that are almost entirely incompatible.
Besides having different properties, Netscape 4 and IE 4 provide
access to Event objects in different ways. In Netscape, an Event
object is passed as an argument to every event handler. For event
handlers defined by HTML attributes, the name of the event argument
is event. In IE, the Event object of the most
recent event is instead stored in the event
property of the Window object.

In addition to the incompatibility between the Netscape 4 Event
object and the IE Event object, the W3C DOM defines its own Event
object that is incompatible with both. See the Event,
UIEvent, and MouseEvent entries in the
DOM reference section.


See Also


Chapter 19; Event, UIEvent, and MouseEvent in the
DOM reference section

/ 844