Files
notes_estom/Python/web_socket_test/index.html
2021-05-09 16:21:02 +08:00

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>