<script src="//cdn.sockjs.org/sockjs-0.3.min.js"></script> <script> var sock = new SockJS(‘http://114.55.72.99:1337/websockets‘) , chat = document.querySelector(‘#chat‘); sock.onmessage = function(e) { var newdiv=document.createElement("div"); var newtext=document.createTextNode("A new div"+e.data); newdiv.appendChild(newtext) ; chat.appendChild(newdiv) }; </script>
时间: 2024-10-12 08:02:20