Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Microsoft equivalent for HTML5 Server-Sent Events?

I am using HTML5 Server-Sent Events as follows:

    SSEUpdate = new EventSource("http://example.com/update.php");     SSEUpdate.onmessage = function(e){       console.log(e.data);     } 

It does not work in IE11. (Error in console: 'EventSource' is undefined) Is there an identical Microsoft equivalent, or do I have to do something completely different?

like image 758
GiantDuck Avatar asked Jun 30 '14 20:06

GiantDuck


People also ask

What is server-sent events in HTML5?

A server-sent event is when a web page automatically gets updates from a server. This was also possible before, but the web page would have to ask if any updates were available. With server-sent events, the updates come automatically.

What is the difference between server-sent events SSEs and WebSockets in HTML5?

Obviously, the major difference between WebSockets and Server-Sent Events is that WebSockets are bidirectional (allowing communication between the client and the server) while SSEs are mono-directional (only allowing the client to receive data from the server).

Which browser does a server-sent event does not support?

BROWSER SUPPORT FOR Server Sent EventsChrome browser version 4 to 5 does not support Server Sent Events property.

What is server-sent events in Java?

What are Server-Sent Events? SSE definition states that it is an http standard that allows a web application to handle a unidirectional event stream and receive updates whenever the server emits data. In simple terms, it is a mechanism for unidirectional event streaming.


2 Answers

In a word, no.

Microsoft has not included SSE or an equivalent of SSE in any version of IE. IMO, you have two good options:

  1. Use a polyfill - My tests with this polyfill in IE10 and IE11 were all successful. Since it starts with if ("EventSource" in global) return;, it'll only run in browsers that do not support EventSource.
  2. Use websockets instead - Although it requires more server-side setup (The ws:// protocol), it works in IE10 and 11 and provides more options such as bi-directional communication.
like image 53
Mooseman Avatar answered Nov 10 '22 10:11

Mooseman


SSE native support for IE is not there. You can achieve same thing using polyfill

like image 39
Prakash N D Avatar answered Nov 10 '22 11:11

Prakash N D