-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswsw.html
27 lines (26 loc) · 1.01 KB
/
swsw.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<script type="text/javascript">
var ws = new WebSocket("ws://localhost:9999 ");
ws.onopen = function() {};
ws.onmessage = function (e) {
alert(e.data)
};
window.onbeforeunload = function() {
ws.send("DISCONNECTED");
ws.onclose = function () {}; // disable onclose handler first
ws.close()
};
</script>
<style media="screen" type="text/css">
body {vertical-align:middle;}
</style>
</head>
<body align="center">
<input id="msg" type="text" value="Hello World!"/>
<button onclick="ws.send(document.getElementById('msg').value);">exec</button>
</body>
</html>