测试网页代码如下
<!DOCTYPE html>
<html>
<head>
<title>测试 websocket 世界最简单案例</title>
</head>
<body>
<script>
var ws = new WebSocket("ws://127.0.0.1:8001/index.html");
ws.onopen = function(){
alert("open");
ws.send("WebSocket");
};
ws.onmessage = function(ev){
alert(ev.data);
};
ws.onclose = function(ev){
alert("close");
};
ws.onerror = function(ev){
console.log(ev);
alert("error");
};
</script>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)