HTML and CSS Reference
In-Depth Information
Table 13.9 Properties of the event Object: Mozilla Firefox (continued)
Property
What It Describes
target
The node from which the event originated.
timestamp
Returns the time (in milliseconds since the epoch) the event was created.
Not all events return a timestamp.
type
A string indicating the type of event, such as “mouseover”, “click”, and so on.
which
Netscape legacy property indicating the Unicode for the key pressed.
Identical to charCode .
modifiers
The bitmask representing modifier keys such as Alt, Shift, Meta, and so on.
data
Array of URLs for dragged and dropped.
height and width
Height and width of the window.
13.7.3 Using Event Object Properties
The srcElement/target and type Properties. The srcElement (Internet Explorer)
and the target properties (Firefox) return the element that fired the event. The srcEle-
ment also has a tagName property: event.srcElement.tagName will return “IMG” if you
click on an image object. And we can also read styles, so if the image has a style height
of 100px, then event.srcElement.style.height will return “100px”.
The type property contains the event name (e.g., click , mouseover , keypress , and so
on). This is the same for nonphysical events. If we capture and handle an onload event,
type will be “load”, and so on.
EXAMPLE 13.21
<html>
<head><title>Event Properties</title></head>
<body bgcolor="yellow"
<!--Internet Explorer has srcElement property-->
<!--Firefox has target property-->
<!--Opera has both-->
1
<form name="form1">
2
<input type=button
value="Internet Explorer"
3
onClick="alert( event.type + ' ' + event.srcElement );">
<input type=button
value="Firefox"
4
onClick="alert( event.type + ' ' + event.target );" />
Continues
 
 
Search WWH ::




Custom Search