SVG
The TimeEvent.initTimeEvent() method initializes the value of a TimeEvent created using Document.createEvent().
This method may only be called before the event has been dispatched via EventTarget.dispatchEvent(). If called multiple times, the final call takes precedence.
[!NOTE] Document.createEvent() is deprecated in favor of event constructors, but
TimeEventhas no dedicated constructor. CustomEvent is not a valid replacement, as it does not produce aTimeEventinstance with the interface'sviewanddetailattributes.
Syntax
initTimeEvent(type)
initTimeEvent(type, view)
initTimeEvent(type, view, detail)
Parameters
type- : A string specifying the event type.
view- : The Window from which the event was generated. If
nullor omitted, the TimeEvent.view attribute of the event will benull. Defaults tonull.
- : The Window from which the event was generated. If
detail- : A
longproviding contextual information about the event. Defaults to0.
- : A
Return value
None (undefined).
Examples
Dispatching a repeatEvent
const evt = document.createEvent("TimeEvent");
evt.initTimeEvent("repeatEvent", window, 2);
svgElement.dispatchEvent(evt);
Specifications
Browser compatibility
See also
- TimeEvent
- Document.createEvent()
- EventTarget.dispatchEvent()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
