sockjs.js websocket api 亲测可用 if(this.websocket==null) { // 首先判断是否 支持 WebSocket if ('WebSocket' in window) { this.websocket = new WebSocket( "ws://"+this.vbshopURL+"/layim/server?id="+id); } else if ('MozWebSocket' in window) { this.websocket = new MozWebSocket( "ws://"+this.vbshopURL+"/layim/server?id="+id); } else { this.websocket = new SockJS( "http://"+this.vbshopURL+"/sockjs/layim/server?id="+id); } }