哔哔one
测试下来,web-socket-js简直可以兼容到底了。因为web-socket-js是基于flash的,所以必须要求要求IE8,IE9必须是FlashPlayer10或者更新的版本。web-socket-js是基于flash的技术,只需要引入两个js文件和一个swf文件,就可以让浏览器用于几乎原生的WebSocket接口。另外,web-socket-js还是需要在ws服务端843端口做一个flash安全策略文件的服务。我自己曾经基于stompjs和web-socket-js,做WebSocket兼容到IE5怪异模式,当然了stompjs在低版本的IE上有兼容性问题,而且stompjs已经不再维护了,你可以使用我fork的一个版本,地址是:https://github.com/wangduandu...主要是老版本IE在正则表达式行为方面有点异常。//fixie8,ie9,RegExpnotnormalproblem//inchrometheframeslengthwillbe2,butinie8,ie9,itwellbe1//bywdd20180321if(frames.length===1){frames.push('')}web-socket-js用法示例websocket服务器的843端口还需要部署一个flash的安全策略文件服务拷贝swfobject.js,web_socket.js,WebSocketMain.swf到响应的目录下编写代码如下//LetthelibraryknowwhereWebSocketMain.swfis:WEB_SOCKET_SWF_LOCATION="WebSocketMain.swf";//WriteyourcodeinthesamewayasfornativeWebSocket:varws=newWebSocket("ws://example.com:10081/");ws.onopen=function(){ws.send("Hello");//Sendsamessage.};ws.onmessage=function(e){//Receivesamessage.alert(e.data);};ws.onclose=function(){alert("closed");};如果你的WebSocket总是断开,可以参考:https://wdd.js.org/websocket-...