Open tjl1979 opened 9 years ago
All versions of IE that have WebSockets also support addEventListener. Which version of IE are you seeing the issue with? Can you post the error message.
I'm also seeing an error in IE (11) - I'll update with the specific error message later, but it was to do with firing custom events on the internally created div
element
It turns out you can't create new events in IE using:
new Event('connecting')
Doing so throws "Object doesn't support this action". I've moved beyond the connecting part to the same error in onopen
by replacing the event code in connect
with:
var ev = document.createEvent("Event");
ev.initEvent('connecting', false, false);
eventTarget.dispatchEvent(ev);
Not sure at this point if it's cross browser (probably not knowing IE) or if browser detection will be needed to run the correct code.
Looks like it should be ok in other browsers, based on this and this SO answer which says:
if(document.createEvent){
//...
}else if(document.createEventObject){// IE < 9
//...
}
implying that createEvent
is fine in IE9 and above, and other browsers. As you've commented above, this is only targetted versions of IE that support websockets, so this should be fine to use across the board I think
Ok, glad I checked before forking and attempting a fix - seems there's already a pull request for exactly this issue :)
Just merged that pull request
IE don't support addEventListener. IE use attachEvent.
How to fixed?