compositionupdate 事件触发于字符被输入到一段文字的时候(这些可见字符的输入可能需要一连串的键盘操作、语音识别或者点击输入法的备选词)
| Bubbles | Yes |
| Cancelable | No |
| Target objects | Element |
| Interface | TouchEvent |
属性
| Property | Type | Description |
|---|---|---|
target 只读 |
EventTarget |
焦点所在的,处理文字输入的元素。 |
type 只读 |
DOMString |
The type of event. |
bubbles 只读 |
boolean |
Does the event normally bubble? |
cancelable 只读 |
boolean |
Is it possible to cancel the event? |
view 只读 |
WindowProxy |
Document.defaultView (the window of the document). |
detail 只读 |
long (float) |
0. |
data 只读 |
DOMString (string) |
要被替换掉的字符串,如果输入时没有字符串被选,则为空字符串。只读。 |
locale 只读 |
DOMString (string) |
输入事件的语言代号,或者空字符串。只读。 |
浏览器兼容性
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Yes)[1] | 9.0 (9.0)[2] | (Yes) | 未实现 | ? |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | ? | 9.0 (9.0)[2] | ? | ? | ? |
[1] 在 compositionstart 事件之后不会立即执行。
[2] compositionupdate 事件在编辑器里的内容改变之前就会触发。自从 Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9) 开始, input 事件在输入过程中、内容变化后就触发。使用它可以在输入过程中就获得新的内容。
Gecko 在可信事件(trusted events)中还不支持 locale 属性。但是开发者可以在使用 initCompositionEvent() 创建不可信事件时指定一个值。