我正在使用HTML5 Server-Sent Events,如下所示:
SSEUpdate = new EventSource("http://example.com/update.php");
SSEUpdate.onmessage = function(e){
console.log(e.data);
}
它在IE11中不起作用。 (控制台出错:'EventSource' is undefined
)是否存在相同的Microsoft等价物,或者我必须做一些完全不同的事情?
答案 0 :(得分:71)
总之,没有。
Microsoft未在任何版本的IE中包含SSE或等效的SSE。 IMO,你有两个不错的选择:
if ("EventSource" in global) return;
开头,因此只会在不支持EventSource
的浏览器中运行。ws://
协议),it works in IE10 and 11并提供更多选项,例如双向通信。答案 1 :(得分:1)
对IE的SSE本机支持不存在。您可以使用polyfill
实现相同的目标