2012-01-03 39 views

回答

2

您可以使用下面的代碼來檢查。

 
var support = "MozWebSocket" in window ? 'MozWebSocket' : ("WebSocket" in window ? 'WebSocket' : null); 
if(support==null) { 
// WebSockets aren't supported 
} 
0

試試這個。

if ('WebSocket' in window) { 
     webSocket = new WebSocket(url); 
} else if ('MozWebSocket' in window) { 
     webSocket = new MozWebSocket(url); 
} else { 
     Console.log('Error: WebSocket is not supported by this browser.'); 
       return; 
} 
相關問題