timeStamp 事件属性

定义和用法

timeStamp 事件属性可返回一个时间戳。指示发生事件的日期和时间(从 epoch 开始的毫秒数)。

epoch 是一个事件参考点。在这里,它是客户机启动的时间。

并非所有系统都提供该信息,因此,timeStamp 属性并非对所有系统/事件都是可用的。

语法

  1. event.timeStamp

实例

下面的例子可获得系统启动开始的事件戳:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function showTimestamp(event)
  5. {
  6. var minutes = 1000*60
  7. x=event.timeStamp;
  8. alert(x/minutes)
  9. }
  10. </script>
  11. </head>
  12.  
  13. <body onmousedown="showTimestamp(event)">
  14.  
  15. <p>Click in the document. An alert
  16. box will alert the timestamp.</p>
  17.  
  18. </body>
  19. </html>