CustomEvent.initCustomEvent()
method initializes a
CustomEvent
object. If the event has already been dispatched, this method does nothing.
Events initialized in this way must have been created with the
Document.createEvent()
method. This method must be called to set the event before it is dispatched, using
EventTarget.dispatchEvent()
. Once dispatched, it doesn't do anything anymore.
Do not use this method anymore, as it is deprecated.
注意:
Rather than using the feature, instead use specific event constructors, like
CustomEvent()
. The page on
创建和触发事件
gives more information about the way to use those.
event.initCustomEvent(type, canBubble, cancelable, detail);
type
DOMString
containing the name of the event.
canBubble
布尔
indicating whether the event bubbles up through the DOM or not.
cancelable
布尔
indicating whether the event is cancelable.
detail
The data passed when initializing the event.
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'CustomEvent' in that specification. |
实时标准 |
Initial definition, but already deprecated in favor of the use of a constructor,
CustomEvent()
|
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
initCustomEvent
弃用
|
Chrome
Yes
|
Edge 14 | Firefox 6 | IE 9 | Opera 11 | Safari 5.1 |
WebView Android
Yes
|
Chrome Android
Yes
|
Firefox Android 6 | Opera Android Yes | Safari iOS Yes |
Samsung Internet Android
Yes
|
完整支持
弃用。不要用于新网站。
见实现注意事项。
CustomEvent
CustomEvent()
.
CustomEvent
initCustomEvent()
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument