ultimatepp/reference/WebSocket/demo.html
cxl 5ba2e29db2 reference: WebSocket
git-svn-id: svn://ultimatepp.org/upp/trunk@6708 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2013-12-31 18:12:37 +00:00

29 lines
646 B
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<button onclick="webs()">Test WebSocket</button>
<script>
function webs() {
if("WebSocket" in window) {
var ws = new WebSocket("ws://localhost:8888");
ws.onopen = function(){
ws.send("Hello server!");
};
ws.onmessage = function(evt){
alert(evt.data);
};
ws.onclose = function(ev) {
};
ws.onerror = function(ev){
alert("Connection error: " + ev.reason);
};
}
}
</script>
</body>
</html>