blob: d6530cb5e517481ff83dccd38de57be78a95d395 [file] [log] [blame]
Jeff Thompson287a3182012-11-11 18:12:20 -08001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
4<html xmlns = "http://www.w3.org/1999/xhtml">
5
6<head>
7 <title>Test WebSocket Support</title>
8
9 <script type="text/javascript">
10
11 function test(){
12 var output = "";
13
14 if ('WebSocket' in window) {
15 output += "This browser support WebSocket.";
16 } else {
17 output += "No WebSocket support.";
18 }
19
20 document.getElementById('result').innerHTML += output;
21
22 console.log("starting websocket...");
23 if ("WebSocket" in window) {
24 var ws = new WebSocket("ws://localhost:9696");
25
26 ws.onopen = function() {
27 console.log("WebSockets connection opened");
28 ws.send("Hello Server (from client).");
29 }
30 ws.onmessage = function(e) {
31 console.log("Got from server: " + e.data);
32 }
33 ws.onclose = function() {
34 console.log("WebSockets connection closed");
35 }
36 } else {
37 alert("No WebSockets support");
38 }
39
40 }
41
42 </script>
43
44</head>
45<body >
46 <button onclick="test()">Test Now!</button>
47
48 <p id="result">Result here: </p>
49
50</body>
51</html>