HTML and CSS Reference
In-Depth Information
JavaScript provides an easy way to find out whether a browser can execute
WebSocket-specific code:
if (window.WebSocket) {
console.log("WebSockets supported.");
// Continue with the rest of the
WebSockets-specific functionality…
}
else {
console.log("WebSockets not supported.");
alert("Consider updating your browser for a
richer experience.");
}
The window.WebSocket statement indicates whether the WebSocket protocol is
implemented in the browser. The following statements are equivalent:
window.WebSocket
"WebSocket" in window
window["WebSocket"]
Each one of them results in the same validation check. You can also check about
any feature support using your browser's developer tools.
Want to see which browsers do support the WebSocket protocol? There is an up-to-
date resource available at http://caniuse.com/#feat=websockets .
At the time of writing, WebSocket is fully supported by Internet Explorer 10+, Firefox
20+,Chrome26+,Safari6+,Opera12.1+,SafariforiOS6+,andBlackberryBrowser
7+.
Search WWH ::




Custom Search