blob: edc74b230637d2e6717bbdbb44b832db2f30c457 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
---
title: EventTarget.fireEvent()
slug: Web/API/EventTarget/fireEvent
translation_of: Web/API/EventTarget/dispatchEvent
translation_of_original: Web/API/EventTarget/fireEvent
---
<p>{{APIRef("DOM Events")}}</p>
<p>{{ Non-standard_header() }}</p>
<h2 id="概述">概述</h2>
<p>这是微软IE浏览器用以替代{{domxref("EventTarget.dispatchEvent()")}}的私有方法,与{{domxref("EventTarget.dispatchEvent()")}}不同的是通过<code>fireEvent()</code> 触发的事件不会触发事件的默认行为,例如,通过fireEvent()触发<input type="checkbox">的点击事件并不会切换checkbox的选中状态</p>
<p>语法</p>
<pre class="syntaxbox"><em>cancelled</em> = <em>target</em>.fireEvent(<em>eventNameWithOn</em>, <em>event</em>)
</pre>
<dl>
<dt>target</dt>
<dd>要触发事件的元素</dd>
<dt>eventNameWithOn</dt>
<dd>要触发事件的名字,前缀为“on”,例如,可以用过"onclick"来触发点击事件</dd>
<dt>event</dt>
<dd>要触发的事件对象</dd>
<dt>cancelled</dt>
<dd>布尔值,事件是否被事件句柄取消</dd>
</dl>
<h2 id="规范">规范</h2>
<p>无此部分的规范</p>
<p>微软的描述: <a href="https://msdn.microsoft.com/en-us/library/ms536423(v=vs.85).aspx">has a description on MSDN</a>.</p>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">浏览器兼容性</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari (WebKit)</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatNo() }}</td>
<td>6 到 10 [1]</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatNo() }}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Phone</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatNo() }}</td>
</tr>
</tbody>
</table>
</div>
<p>[1]: fireEvent()在IE11+已经不再支持,{{domxref("EventTarget.dispatchEvent()")}}在IE9+已经支持</p>
<h2 id="相关链接">相关链接</h2>
<ul>
<li><a href="http://help.dottoro.com/ljvtddtm.php">Dottoro Web Reference article</a></li>
</ul>
|