WebSocket 相关知识
2020-12-13 03:20
标签:style blog class code java c 检测浏览器是否支持WebSocket 第二种检测WebSocket支持情况的写法: ws:// --- WebSocket连接 wss:// --- 安全的WebSocket连接 创建对象、连接服务器 WebSocket 相关知识,搜素材,soscw.com WebSocket 相关知识 标签:style blog class code java c 原文地址:http://www.cnblogs.com/iwenr/p/3725393.htmlvar WebSocketsExist = true;
try {
var dummy = new WebSocket("ws://localhost:8989/test");
} catch (ex) {
try
{
webSocket = new MozWebSocket("ws://localhost:8989/test");
}
catch(ex)
{
WebSocketsExist = false;
}
}
if (WebSocketsExist) {
// 支持
} else {
// 不支持
}
function IstSupportWebSocket() {
if (window.WebSocket) {
//supported
} else {
// not supported
}
}
url = "ws://localhost:8080/echo";
w = new WebSocket(url);
下一篇:linux上安装php