This indicates the exact time (in milliseconds) when the event occurred. This should be equivalent to having called Date.getUTCMilliseconds() to obtain a measurement of the number of milliseconds since midnight on the first of January 1970.
The example demonstrates how this might be used to display an alert() dialog that indicates the number of milliseconds that have elapsed since the page was loaded.
The time stamp value here is the time the event was triggered. This is important because if you measure the time during an event handler, that may be some time after the event occurred. It may be important to collect a series of events and arrange them into sequence. The trigger time allows you to do this.
The standard expects that this may not always be availabl,e and that in such cases a value of zero should be returned.
This feature appears to manifest a bug and unfortunately the Event object does not seem to work with this property in the initial release of Netscape 6.0. This event model is a completely new implementation based on the DOM level 2 standard and so we might expect some instabilities in the early days.
<HTML> <HEAD> <SCRIPT> myLoadTime = new Date().getTime(); </SCRIPT> </HEAD> <BODY> <SCRIPT> document.write(myLoadTime); </SCRIPT> <HR> <INPUT TYPE="BUTTON" VALUE="TOM" ONCLICK="measureTime(event);"> <SCRIPT> function measureTime(anEvent) { alert((anEvent.timeStamp - myLoadTime)); } </SCRIPT> </BODY> </HTML>
See also: | Date object, Date.getUTCMilliseconds() |
Prev | Home | Next |
Event.target | Up | Event.toElement |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |