mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
29 lines
646 B
HTML
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>
|