--- title: Event.cancelBubble slug: Web/API/Event/禁用时间冒泡 tags: - 事件 translation_of: Web/API/Event/cancelBubble ---
{{APIRef("DOM Events")}}
Event.cancelBubble
属性是 {{domxref("Event.stopPropagation()")}}的一个曾用名。在从事件处理程序返回之前将其值设置为true可阻止事件的传播。
event.cancelBubble = bool; let bool = event.cancelBubble;
ele.onclick = function(e) { // 在这儿可以做点儿有趣的事情 e.cancelBubble = true; }
这个属性的规范并未统一. 因为他还有其他标准 W3C版: an old Working Draft of W3C DOM Level 2. 微软版: description of it on MSDN.
{{ CompatibilityTable() }}
Feature | Firefox (Gecko) | Chrome | Edge | Internet Explorer | Microsoft Edge | Opera | Safari |
---|---|---|---|---|---|---|---|
Basic support | {{ CompatNo() }} | {{ CompatVersionUnknown() }} | {{CompatVersionUnknown}} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} |
Feature | Firefox Mobile (Gecko) | Android | Edge | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{CompatVersionUnknown}} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |