-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
27 lines (27 loc) · 735 Bytes
/
test.html
File metadata and controls
27 lines (27 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text" id="test">
</body>
<script type="text/javascript">
var node = document.querySelector('#test');
node.addEventListener('compositionstart', function(e){
e.target.composing = true;
})
node.addEventListener('compositionend', function(e){
e.target.composing = false;
var event = document.createEvent('HTMLEvents');
event.initEvent('input', true, true);
e.target.dispatchEvent(event);
})
node.addEventListener('input', function(e){
if(!e.target.composing){
console.log(e, e.target.composing);
}
});
</script>
</html>