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

The detail readonly property of the CustomEvent interface returns any data passed when initializing the event.

Note: This feature is available in Web Workers.

Syntax

 let myDetail = customEventInstance.detail;

Return value

Whatever data the event was initialized with.

Example

// add an appropriate event listener
obj.addEventListener("cat", function(e) { process(e.detail) });

// create and dispatch the event
let event = new CustomEvent("cat", {
  detail: {
    hazcheeseburger: true
  }
});
obj.dispatchEvent(event);

// Will return an object contaning the hazcheeseburger property
let myDetail = event.detail;

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 11Edge ? Firefox Full support 11IE No support NoOpera Full support 11.6Safari No support No
Notes
No support No
Notes
Notes Available on Nightly build (535.2)
WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 14Opera Android Full support YesSafari iOS No support No
Notes
No support No
Notes
Notes Available on Nightly build (535.2)
Samsung Internet Android ?

Legend

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

See also

 

文件標籤與貢獻者

此頁面的貢獻者: fscholz, chrisdavidmills
最近更新: fscholz,