課程
/前端開發(fā)
/HTML/CSS
/基于Websocket的火拼俄羅斯(基礎(chǔ))
文本框內(nèi)的文字發(fā)送不出去。點(diǎn)擊發(fā)送也沒(méi)反應(yīng),該怎么辦?
2018-02-27
源自:基于Websocket的火拼俄羅斯(基礎(chǔ)) 2-1
正在回答
?<input?type="sendTxt"?name="text"?/> ?你這個(gè)得換成?<input id="sendTxt" type="text" /> 就可以了
?
<input?type=
"sendTxt"
name=
"text"
/> ?你這個(gè)得換成?<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">發(fā)送</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>
舉報(bào)
HTML5火拼俄羅斯基礎(chǔ)講解。
2 回答為啥消息不能發(fā)送過(guò)去
3 回答socket.emit 發(fā)送不了信息呢
2 回答發(fā)送消息在對(duì)方界面不顯示
4 回答我的在本地跑不起來(lái)也不報(bào)錯(cuò)
1 回答websocket 服務(wù)器連接不上 觸發(fā)不了onopen
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2019-05-22
?
<input?type=
"sendTxt"
?name=
"text"
?/> ?你這個(gè)得換成?<input id="sendTxt" type="text" /> 就可以了
2018-02-27