Chrome_查看 webSocket 连接信息

时间:2025-03-21 11:39:34
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>WebSocket</title> 6 </head> 7 <body> 8 <h1>Echo Test</h1> 9 <input type="text" id="sendTxt"> 10 <button id="sendBtn">发送</button> 11 <div id="recv"></div> 12 <script type="text/javascript"> 13 var websocket = new WebSocket("ws:///"); 14 = function(){ 15 ("websocket open"); 16 ("recv").innerHTML = "Connected"; 17 } 18 = function(){ 19 ('websocket close'); 20 } 21 = function(e){ 22 (); 23 ("recv").innerHTML = ; 24 } 25 ("sendBtn").onclick = function(){ 26 var txt = ("sendTxt").value; 27 (txt); 28 } 29 30 </script> 31 </body> 32 </html>