Windows Edge and opening blob url

I get some odd results when I try to open a new window with a blob URL in Windows Edge (20.10240.16384, which is the version in IE11 VM provided by Microsoft).

var xhr = new XMLHttpRequest(); xhr.open('POST', sourceUrl, true); xhr.responseType = 'blob'; xhr.onload = function(e,form) { if (this.status == 200) { var blob = this.response; var url = window.URL.createObjectURL(blob); var w = window.open(url); } } 

In line

 var w = window.open(url); 

I get an โ€œAccess Deprivedโ€ error that looks related to CORS, which makes little sense since it is not technically the same domain. However, the BLOB URL does not technically have a domain?

Is this a bug in Edge? Or am I doing something wrong? This code works in IE, Chrome, etc.

+5
source share
1 answer

I found a solution for both IE and Edge.

 if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob); } else { var objectUrl = URL.createObjectURL(blob); window.open(objectUrl); } 

Link Here

+1
source

All Articles