我正在尝试为浏览器做一个web套接字实现。Firefox,Chrome工作得很好,但是当我尝试使用IE时,它创建了套接字对象,但从不调用计时器。
WebSocket = function(url, protocol, proxyHost, proxyPort, headers) {
var self = this;
self.__id = WebSocket.__nextId++;
WebSocket.__instances[self.__id] = self;
self.readyState = WebSocket.CONNECTING;
self.bufferedAmount = 0;
self.__events = {};
// Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc.
// Otherwise, when onopen fires immediately, onopen is called before it is set.
setTimeout(function() {
WebSocket.__addTask(function() {
WebSocket.__flash.create(
self.__id, url, protocol, proxyHost || null, proxyPort || 0, headers || null);
});
}, 0);
};可能是什么原因?
发布于 2011-04-27 09:56:52
你在说什么版本的IE?你在使用什么websocket库?
旧版本的IE不支持Web套接字。我认为你需要用长轮询代替websockets来处理那些旧浏览器.
如果您使用的是:https://github.com/gimite/web-socket-js,则在文档中说明:
它应该工作: Google 4或更高版本(仅使用本机实现)火狐3.x、4.x、Internet 8、9+ Flash 10或更高版本,它可能在其他浏览器(如Safari、Opera或IE 6 )上工作,也可能无法工作。欢迎为这些浏览器提供修补程序,但我不会自己解决这些浏览器特有的问题。
https://stackoverflow.com/questions/5802092
复制相似问题