Untitled-1.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. </div>
  12. <div id="container"></div>
  13. <input type="text" id="first" value="nick">
  14. <input type="text" id="second" value="message">
  15. <input type="button" value="send" id="button">
  16. <script>
  17. const socket = io("http://socketchat.ed.asmer.org.ua/")
  18. socket.on('msg', msg => console.log(msg))
  19. const div = document.createElement("div")
  20. div.innerHTML = `<strong>${first.value}</strong>: ${second.value}`
  21. container.append(div)
  22. button.onclick = () => {
  23. console.log( ` ${first.value}: ${second.value} `)
  24. }
  25. socket.emit('msg', {first:first.value, second:second.value})
  26. </script>
  27. <script>
  28. </script>
  29. </body>
  30. </html>