Event.timeStamp (Property)

A time value at which the event was triggered.

Availability:

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.

Warnings:

Example code:

   <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()

Property attributes:

ReadOnly.