blob: c228d329d6709aa67144e5467e3ca504aacc0f8f (
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: Event.cancelBubble
slug: Web/API/Event/禁用时间冒泡
tags:
- 事件
translation_of: Web/API/Event/cancelBubble
---
<p>{{APIRef("DOM Events")}} </p>
<p><code><strong>Event.cancelBubble</strong></code> 属性是 {{domxref("Event.stopPropagation()")}}的一个曾用名。在从事件处理程序返回之前将其值设置为true可阻止事件的传播。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox">event.cancelBubble = <em>bool;</em>
<em>let bool</em> = event.cancelBubble;</pre>
<h2 id="用例">用例</h2>
<dl>
<dt>
<pre class="syntaxbox">ele.onclick = function(e) {
// 在这儿可以做点儿有趣的事情
e.cancelBubble = true;
}</pre>
</dt>
</dl>
<h2 id="规范">规范</h2>
<p><em>这个属性的规范并未统一.</em> 因为他还有其他标准 W3C版: <a href="http://www.w3.org/TR/1999/WD-DOM-Level-2-19990304/events.html#attribute-cancelBubble">an old Working Draft of W3C DOM Level 2</a>. 微软版: <a href="https://msdn.microsoft.com/en-us/library/ms533545(v=vs.85).aspx">description of it 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>Firefox (Gecko)</th>
<th>Chrome</th>
<th>Edge</th>
<th>Internet Explorer</th>
<th>Microsoft Edge</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Firefox Mobile (Gecko)</th>
<th>Android</th>
<th>Edge</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<h2 id="参考">参考</h2>
<ul>
<li>{{domxref("UIEvent.cancelBubble")}}</li>
<li>translated by cnvoid</li>
</ul>
|