blob: 59bc214280bdf08cdd7f8def2ce32e69923ce578 (
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
|
---
title: Event.isTrusted
slug: Web/API/Event/isTrusted
translation_of: Web/API/Event/isTrusted
---
<p>{{APIRef("DOM")}}</p>
<p>{{domxref("Event")}} 介面的 <code>isTrusted</code> 唯讀屬性為一個布林值,若事件物件是由使用者操作而產生,則 <code>isTrusted</code> 值為 <code>true</code>。若事件物件是由程式碼所建立、修改,或是透過 {{domxref("EventTarget.dispatchEvent()")}} 來觸發,則 <code>isTrusted</code> 值為 <code>false</code>。</p>
<h2 id="Syntax" name="Syntax">語法</h2>
<pre class="syntaxbox">var bool = event.isTrusted;
</pre>
<h2 id="範例">範例</h2>
<pre> if (e.isTrusted) {
/* The event is trusted. */
} else {
/* The event is not trusted. */
}
</pre>
<h2 id="規範">規範</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-event-istrusted', 'Event.isTrusted')}}</td>
<td>{{ Spec2('DOM WHATWG') }}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('DOM3 Events', '#trusted-events', 'Trusted events')}}</td>
<td>{{Spec2('DOM3 Events')}}</td>
<td>Adds requirements regarding trusted and untrusted events, though it does not itself define the <code>isTrusted</code> property.</td>
</tr>
<tr>
<td>{{SpecName('DOM4', '#dom-event-istrusted', 'Event.isTrusted')}}</td>
<td>{{Spec2('DOM4')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
{{Compat("api.Event.isTrusted")}}
|