Event.timeStamp (Property)

A time value at which the event was triggered.


DOM level - 2
JavaScript - 1.5
Netscape - 6.0
Property/method value type:Number primitive
JavaScript syntax:NmyEvent.timeStamp

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.


Example code:

   myLoadTime = new Date().getTime();
   <INPUT TYPE="BUTTON" VALUE="TOM" ONCLICK="measureTime(event);">
   function measureTime(anEvent)
      alert((anEvent.timeStamp - myLoadTime));

See also:Date object, Date.getUTCMilliseconds()

Property attributes: