index.html 797 B

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>
  5. Static File Index.HTML
  6. </title>
  7. <script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js'></script>
  8. </head>
  9. <body>
  10. <div id='formContainer'>
  11. <input id="nickname" type="text">
  12. <input id="msg" type="text">
  13. <button id="button">enter</button>
  14. </div>
  15. <script>
  16. const socket = io("http://socketchat.ed.asmer.org.ua/")
  17. socket.emit('msg', { nick: "test", message: "txt" })
  18. socket.on('msg', msg => {
  19. console.log(msg)
  20. let p = document.createElement("div")
  21. document.body.append(p)
  22. p.innerHTML = msg.nick
  23. })
  24. button.onclick = function () {
  25. socket.emit('msg', { nick: "test", message: "txt" })
  26. }
  27. </script>
  28. </body>
  29. </html>