Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (42 sloc) 976 Bytes
<script type="text/javascript">
function WebSocketTest()
if ("WebSocket" in window)
alert("WebSocket is supported by your Browser!");
// Let us open a web socket
var ws = new WebSocket("ws://localhost:9998/echo");
ws.onopen = function()
// Web Socket is connected, send data using send()
ws.send("Message to send");
alert("Message is sent...");
ws.onmessage = function (evt)
var received_msg =;
alert("Message is received...");
ws.onclose = function()
// websocket is closed.
alert("Connection is closed...");
// The browser doesn't support WebSocket
alert("WebSocket NOT supported by your Browser!");
<div id="sse">
<a href="javascript:WebSocketTest()">Run WebSocket</a>