課程
/前端開發
/HTML/CSS
/基于Websocket的火拼俄羅斯(基礎)
文本框內的文字發送不出去。點擊發送也沒反應,該怎么辦?
2018-02-27
源自:基于Websocket的火拼俄羅斯(基礎) 2-1
正在回答
?<input?type="sendTxt"?name="text"?/> ?你這個得換成?<input id="sendTxt" type="text" /> 就可以了
?
<input?type=
"sendTxt"
name=
"text"
/> ?你這個得換成?<input id="sendTxt" type="text" /> 就可以了
77193617
<!DOCTYPE?html> <html> <head> <meta?charset="utf-8"?/> <title>Websocket</title> </head> <body> <h1>Echo?Test</h1> <input?type="sendTxt"?name="text"?/> <button?id="sendBtn">發送</button> <div?id="recv"></div> <script?type="text/javascript"> var?websocket?=?new?WebSocket("ws://echo.websocket.org/"); websocket.onopen?=?function(){ console.log('websocket?open'); document.getElementById("recv").innerHTML?=?"Connected"; } websocket.onclose?=?function(){ console.log('websocket?close'); } websocket.onmessage?=?function(e){ console.log(e.data); document.getElementById("recv").innerHTML?=?e.data; } document.getElementById("sendBtn").onclick?=?function(){ var?txt?=?document.getElementById("sendTxt").value; websocket.send(txt); }? </script> </body> </html>
舉報
HTML5火拼俄羅斯基礎講解。
2 回答為啥消息不能發送過去
3 回答socket.emit 發送不了信息呢
2 回答發送消息在對方界面不顯示
4 回答我的在本地跑不起來也不報錯
1 回答websocket 服務器連接不上 觸發不了onopen
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2019-05-22
?
<input?type=
"sendTxt"
?name=
"text"
?/> ?你這個得換成?<input id="sendTxt" type="text" /> 就可以了
2018-02-27