54f193051b
modifié: test.html
32 lines
1.2 KiB
HTML
32 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<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>
|