Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (28 sloc) 0.636 kB
<!doctype html>
<html>
<head>
<title>Chat</title>
<script src="http://localhost:8080/socket.io/socket.io.js"></script>
<script>
var yourName = prompt('What is your name?')
var socket = io.connect('http://localhost:8080')
socket.on('msg', function(data){
display(data)
})
function sendMsg(){
socket.emit('msg', yourName + ': ' + inputField.value)
display(yourName + ': ' + inputField.value)
inputField.value = ''
}
function display(msg){
log.innerHTML += msg + '<br>'
}
</script>
</head>
<body>
<form onsubmit="sendMsg(); return false;">
<input id="inputField" type="text" size="50"/>
</form>
<pre id="log"></pre>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.