21 lines
572 B
HTML
21 lines
572 B
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>WebSocket demo</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<script>
|
||
|
var ws = new WebSocket("ws://127.0.0.1:3000/"),
|
||
|
messages = document.createElement('ul');
|
||
|
ws.onmessage = function (event) {
|
||
|
var messages = document.getElementsByTagName('ul')[0],
|
||
|
message = document.createElement('li'),
|
||
|
content = document.createTextNode(event.data);
|
||
|
message.appendChild(content);
|
||
|
messages.appendChild(message);
|
||
|
};
|
||
|
document.body.appendChild(messages);
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|