HTML and CSS Reference
p.textContent = s;
// Start running the example.
After running the web page, the output should look similar to the following:
WebSocket Sample Client
Message received: Hello WebSocket!
If you see this output, congratulations! You've successfully created and executed
your first sample WebSocket client application. If the example does not work, you'll need
of your browser. It is possible, though increasingly unlikely, that your browser does not
support WebSocket. While the latest versions of every major browser contain support for
the WebSocket API and protocol, there are still some older browsers in use that do not have
this support. The next section shows you how to ensure your browser supports WebSocket.
Checking for WebSocket Support
Since (surprisingly) not all web browsers support WebSocket natively yet, it's good
practice to include in your code a way to determine the browser support and, if possible,
provide a fallback. Most modern browsers support WebSocket, but depending on your
users, you'll likely want to use one of these techniques to cover your bases.
Chapter 8 discusses various WebSocket fallback and emulation options.