modifié: superTornado.py

modifié:         test.html
This commit is contained in:
sidya82
2014-02-27 21:38:17 +01:00
parent 493e758031
commit 54f193051b
2 changed files with 41 additions and 37 deletions

View File

@ -1,30 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<script>
function fun(){
alert("in fun()");
var val=document.getElementById("txt");
var ws = new WebSocket("ws://192.168.1.23/test:80");
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>
<head>
<meta charset="utf-8">
<script type="text/javascript">
var messageContainer = document.getElementById("messages");
function WebSocketTest() {
if ("WebSocket" in window) {
messageContainer.innerHTML = "WebSocket is supported by your Browser!";
var ws = new WebSocket("ws://localhost:8888/?Id=123456789");
ws.onopen = function() {
ws.send("Message to send");
};
ws.onmessage = function (evt) {
var received_msg = evt.data;
messageContainer.innerHTML = "Message is received...";
};
ws.onclose = function() {
messageContainer.innerHTML = "Connection is closed...";
};
} else {
messageContainer.innerHTML = "WebSocket NOT supported by your Browser!";
}
}
</script>
</head>
<body>
<a href="javascript:WebSocketTest()">Run WebSocket</a>
<div id="messages" style="height:200px;background:black;color:white;"></div>
</body>
</html>