HTML and CSS Reference
In-Depth Information
<head>
<title>HTML5 WebSockets</title>
<link rel="stylesheet" href="style.css" />
<script src="chat.js"></script>
</head>
<body>
<h1> HTML5 WebSocket chat. </h1>
<input type="text" id="text-view" />
<input type="button" id="send-button"
value="Send!" />
<input type="button" id="stop-button"
value="Stop" />
</br>
<label id="status-label">Status</label>
</body>
</html>
chat.js
All the JavaScript code for the chatting functionality is as follows:
window.onload = function() {
var textView =
document.getElementById("text-view");
var buttonSend =
document.getElementById("send-button");
var buttonStop =
document.getElementById("stop-button");
var label =
document.getElementById("status-label");
var socket = new
WebSocket("ws://echo.websocket.org");
socket.onopen = function(event) {
label.innerHTML = "Connection open";
}
Search WWH ::




Custom Search