websocket 增加多分组 fork https://github.com/olahol/melody
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
591 B

10 years ago
  1. <html>
  2. <head>
  3. <title>Melody example: file watching</title>
  4. </head>
  5. <style>
  6. #file {
  7. text-align: left;
  8. background: #f1f1f1;
  9. width: 500px;
  10. min-height: 300px;
  11. padding: 20px;
  12. }
  13. </style>
  14. <body>
  15. <center>
  16. <h3>Watching a file</h3>
  17. <pre id="file"></pre>
  18. </center>
  19. <script>
  20. var url = 'ws://' + window.location.host + '/ws';
  21. var c = new WebSocket(url);
  22. c.onmessage = function(msg){
  23. var el = document.getElementById("file");
  24. el.innerText = msg.data;
  25. }
  26. </script>
  27. </body>
  28. </html>