我們的志工尚未將本文翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!
您也可以閱讀本文的 English (US) 版本。

The Event.cancelBubble property is a historical alias to Event.stopPropagation(). Setting its value to true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See Browser compatibility for details. 

Syntax

event.cancelBubble = bool;
var bool = event.cancelBubble;

Example

elem.onclick = function(e) {
 // do cool things here
  e.cancelBubble = true;
}

Specifications

Specification Status Comment
DOM
The definition of 'cancelBubble' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support Yes
Notes
Full support Yes
Notes
Notes Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Edge Full support YesFirefox Full support 53
Notes
Full support 53
Notes
Notes Prior to Firefox 53, this property was defined on the UIEvent interface. See bug 1298970 for more details.
IE Full support YesOpera Full support Yes
Notes
Full support Yes
Notes
Notes Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Safari Full support YesWebView Android Full support Yes
Notes
Full support Yes
Notes
Notes Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Chrome Android Full support Yes
Notes
Full support Yes
Notes
Notes Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Edge Mobile Full support YesFirefox Android Full support 53
Notes
Full support 53
Notes
Notes Prior to Firefox 53, this property was defined on the UIEvent interface. See bug 1298970 for more details.
Opera Android Full support Yes
Notes
Full support Yes
Notes
Notes Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Safari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

文件標籤與貢獻者

最近更新: fscholz,