initMouseEvent method
Initializes a new mouse event that the createEvent method created.
createEvent()/initEvent() constructor pattern for synthetic events is deprecated. See the Synthetic Events page for more information.![]() ![]() |
Syntax
object.initMouseEvent(eventType, canBubble, cancelable, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg)Parameters
- eventType [in]
-
Type: String
One of the following values, or a user-defined custom event type.
-
An onclick event. A mouse button is clicked over an element. A click is a mousedown event and mouseup event in the same location. The value of detailArg increases for each click in the same area.
-
An ondblclick event. A mouse button is double-clicked over an element.
-
An onmousedown event. A mouse button is pressed over an element.
-
An onmousemove event. The mouse pointer moves over an element.
-
An onmouseout event. The mouse pointer moves outside the boundaries of an element.
-
An onmouseover event. The mouse pointer moves into the boundaries of an element.
-
An onmouseup event. A mouse button is released over an element.
- canBubble [in]
-
Type: Boolean
- cancelable [in]
-
Type: Boolean
- viewArg [in]
-
Type: IHTMLWindow2
The active window object or null. This value is returned in the view property of the event. - detailArg [in]
-
Type: Integer
A number that can provide additional information about the event. This value is returned in the detail property of the event.
- screenXArg [in]
-
Type: Integer
The x-coordinate of the mouse pointer, relative to the upper-left corner of the screen. This value is returned in the screenX property of the event.
- screenYArg [in]
-
Type: Integer
The y-coordinate of the mouse pointer, relative to the upper-left corner of the screen. This value is returned in the screenY property of the event.
- clientXArg [in]
-
Type: Integer
The x-coordinate of the mouse pointer, relative to the upper-left corner of the browser's client area. This value is returned in the clientX property of the event.
- clientYArg [in]
-
Type: Integer
The y-coordinate of the mouse pointer, relative to the upper-left corner of the browser's client area. This value is returned in the clientY property of the event.
- ctrlKeyArg [in]
-
Type: Boolean
The value that is returned in the ctrlKey property of the event.
- altKeyArg [in]
-
Type: Boolean
The value that is returned in the altKey property of the event.
- shiftKeyArg [in]
-
Type: Boolean
The value that is returned in the shiftKey property of the event.
- metaKeyArg [in]
-
Type: Boolean
The value that is returned in the metaKey property of the event.
- buttonArg [in]
-
Type: Number
The mouse button that caused the event. This value is returned in the button property of the event.
- relatedTargetArg [in]
-
Type: IEventTarget
A reference to the related element. For more information about how related elements are used with mouse events, see relatedTarget.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Standards information
- Document Object Model (DOM) Level 3 Events Specification, Section 5.2.3
See also

