This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
2014-02-27 20:22:02 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
function fun(){
|
|
|
|
|
|
|
|
alert("in fun()");
|
|
|
|
|
|
|
|
var val=document.getElementById("txt");
|
2014-02-27 20:26:32 +00:00
|
|
|
var ws = new WebSocket("ws://192.168.1.23:80");
|
2014-02-27 20:22:02 +00:00
|
|
|
|
|
|
|
ws.onopen = function(evt) { alert("Connection open ...");
|
|
|
|
ws.send(val.value); };
|
|
|
|
ws.onmessage = function(evt) {
|
|
|
|
alert("from server: "+evt.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
ws.onclose = function(evt) {
|
|
|
|
alert("Connection closed.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body bgcolor="#FFFFFF">
|
|
|
|
<input type="text" id="txt" />
|
|
|
|
<button onClick="fun()">click</button>
|
|
|
|
</body>
|
|
|
|
</html>
|