web api instance method
TimeEvent: initTimeEvent() method
The TimeEvent.initTimeEvent() method initializes the value of a TimeEvent created using createEvent().
This method may only be called before the event has been dispatched via dispatchEvent(). If called multiple times, the final call takes precedence.
[!NOTE]
createEvent()is deprecated in favor of event constructors, butTimeEventhas no dedicated constructor.CustomEventis 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.
viewOptionaldetailOptional- : 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
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.