【www.bbyears.com--WebService】
word-wrap: break-word; margin: 5px 0px; color: rgb(0, 0, 0); font-family: 'sans serif', tahoma, verdana, helvetica; font-size: 13.3333px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">本文属于nodejs+websocket实时聊天系统的改进版本,具体内容如下
client.html:
"; document.getElementById("send").onclick = function (e) { ws.send(input.value + "说:" + value1.value); value1.value = " "; } document.onkeydown = function (e) { e = e || window.event; if (e.keyCode == 13) { document.getElementById("send").onclick(); return false; } } } ws.onclose = function (e) { console.log("服务器关闭"); } ws.onerror = function () { console.log("连接出错"); } /** * 客户端主动断开连接 * * **/ close.onclick = function () { ws.onclose(); ws.send(input.value + 'close' + "了连接"); input.removeAttribute("readOnly"); conn.disabled = false; close.disabled = true; } } } </script>