aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/api/event/timestamp/index.html
blob: 3ec006a09edc1cb2f639cc99caee7187f95fd39f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: Event.timeStamp
slug: Web/API/Event/timeStamp
translation_of: Web/API/Event/timeStamp
---
<div>{{ApiRef("DOM")}}</div>

<h2 id="Summary" name="Summary">說明</h2>

<p>回傳事件建立的時間(單位是毫秒;從 epoch 開始計算)。</p>

<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="syntaxbox">event.timeStamp
</pre>

<h2 id="Examples" name="Examples">範例</h2>

<pre><em>var number</em> = event.timeStamp;
</pre>

<p>下面是一個較為完整的範例:</p>

<pre class="brush: html">&lt;html&gt;
&lt;head&gt;

&lt;title&gt;timeStamp example&lt;/title&gt;

&lt;script type="text/javascript"&gt;
function getTime(event) {
  document.getElementById("time").firstChild.nodeValue = event.timeStamp;
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body onkeypress="getTime(event)"&gt;

&lt;p&gt;Press any key to get the current timestamp
for the onkeypress event.&lt;/p&gt;
&lt;p&gt;timeStamp: &lt;span id="time"&gt;-&lt;/span&gt;&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>

<h2 id="Notes" name="Notes">注意</h2>

<p>這個 property 僅在瀏覽器支持該事件才會有用。</p>

<h2 id="Specification" name="Specification">詳細資料</h2>

<ul>
 <li><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-Event-timeStamp">timestamp </a></li>
</ul>