mirror of
https://github.com/Estom/notes.git
synced 2026-02-03 18:44:19 +08:00
24 lines
516 B
HTML
24 lines
516 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>WebSocket Test</title>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
var wsObj = new WebSocket("ws://127.0.0.1:5678"); //建立连接
|
|
wsObj.onopen = function(){ //发送请求
|
|
alert("open");
|
|
wsObj.send("admin:123456");
|
|
};
|
|
wsObj.onmessage = function(ev){ //获取后端响应
|
|
alert(ev.data);
|
|
};
|
|
wsObj.onclose = function(ev){
|
|
alert("close");
|
|
};
|
|
wsObj.onerror = function(ev){
|
|
alert("error");
|
|
};
|
|
</script>
|
|
</body>
|
|
</html> |