ws.htm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>${context.getContextName()}</title>
  5. <meta charset="UTF-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  8. <meta name="viewport" content="width=device-width,initial-scale=1"/>
  9. <meta name="Author" content="${context.getContextName()}" />
  10. ${Scripts.src("/zinc/zhiqim_v1.4.0.r2018010101.min.js")}
  11. <script>
  12. var ws = null;
  13. Z.onload(function()
  14. {
  15. ws = new WebSocket("ws://"+location.hostname+":"+location.port+"/service/ws", "zoa_announcement");
  16. ws.onopen = function(){console.log("ws.onopen");};
  17. ws.onclose = function(e){console.log("ws.onclose");};
  18. ws.onerror = function(e){console.log("ws.onerror");};
  19. ws.onmessage = function(e){console.log("ws.onmessage:"+e.data);if (e.data == "zoa_announcement_new"){top.Z.alert("有新的公告发布,请在方便的时候进入阅读,谢谢!");}};
  20. Z.timer(1000, 100, null, send);
  21. });
  22. function send()
  23. {
  24. console.log("中文");
  25. ws.send("一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十");
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. index.htm
  31. <br><br>
  32. <a href="abc.htm">abc.htm</a>
  33. <a href="jdk-7u80-windows-x64.exe">下载</a>
  34. </body>
  35. </html>