initCompositionEvent method

Initializes a new text composition event that the createEvent method created.

Important  As of Microsoft Edge, the createEvent()/initEvent() constructor pattern for synthetic events is deprecated. See the Synthetic Events page for more information.
Document Object Model (DOM) Level 3 Events Specification, Section 5.2.7Internet Explorer 9



var retval = CompositionEvent.initCompositionEvent(eventType, canBubble, cancelable, viewArg, data, locale);


eventType [in]

Type: String

One of the following values, or a user-defined custom event type.


Text input is complete. If character data is available, this event is followed by a textInput event with the appropriate inputMethod value.


A text input system starts composing a passage of text.


New characters are added to the data attribute. This event is optional depending on the input method.

canBubble [in]

Type: Boolean

true (true)

The event should propagate upward.

false (false)

The event does not propagate upward.

cancelable [in]

Type: Boolean

true (true)

The default action can be canceled.

false (false)

The default action cannot be canceled.

viewArg [in]

Type: IHTMLWindow2

The active window object or null. This value is returned in the view attribute of the event.
data [in]

Type: String

The composition data. This value is returned in the data attribute of the event.

locale [in]

Type: String

The locale name. This value is returned in the locale attribute of the event.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

See also