--- title: event.timeStamp slug: Web/API/Event/timeStamp tags: - API - DOM - Event - timeStamp translation_of: Web/API/Event/timeStamp ---
返回事件发生时的时间戳.
var number = event.timeStamp;
<html> <head> <title>timeStamp example</title> <script type="text/javascript"> function getTime(event) { document.getElementById("time").firstChild.nodeValue = event.timeStamp; } </script> </head> <body onkeypress="getTime(event)"> <p>按下任意键获取onkeypress事件对象的timestamp属性值.</p> <p>timeStamp: <span id="time">-</span></p> </body> </html>
此属性仅适用于事件系统支持该属性的特定事件类型.