-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
33 lines (30 loc) · 853 Bytes
/
index.html
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
28
29
30
31
32
33
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World with Socket.io</title>
</head>
<body>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io("http://localhost:3000");
var send = function(){
var text = document.getElementById('m').value;
socket.emit('chat', text)
}
var receive = function(msg){
var li = document.createElement('li');
li.innerText = msg;
document.getElementById('messages').appendChild(li);
}
socket.on('chat' , receive);
</script>
<div>
<ul id="messages"> </ul>
<div class="zone_saisie">
<input type="text" id="m" />
<button onclick="send()"> send </button>
</div>
</div>
</body>
</html>