MouseEvent.initMouseEvent() is marked Deprecated on MDN. Engines still implement it for createEvent compatibility. New code should use new MouseEvent().
✓ Deprecated
MouseEvent.initMouseEvent()
Legacy initializer for createEvent("MouseEvents"). Prefer MouseEvent() constructor. Still present for backward compatibility.
—Deprecated
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
initMouseEventLegacy only
Bottom line: Understand it for old codebases; do not add it to new features. See the MDN initMouseEvent reference.
Frequently Asked Questions
It initializes a mouse event created with document.createEvent("MouseEvents"). You set type, bubble/cancelable flags, window, detail, coordinates, modifier keys, button, and relatedTarget before dispatchEvent.
Yes. MDN marks MouseEvent.initMouseEvent() as Deprecated. Do not use it in new code. Prefer the MouseEvent() constructor instead.
Use new MouseEvent(type, options) and dispatch with target.dispatchEvent(event). That is the modern Creating and dispatching events pattern on MDN.
document.createEvent is also obsolete. Some browsers still support createEvent("MouseEvents") plus initMouseEvent for compatibility, but both belong to the old DOM Events Level 2 workflow.
None. initMouseEvent returns undefined. It mutates the event object in place.
Only for some types such as mouseover and mouseout. For click, mousedown, mouseup, and similar, pass null.