Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blob download is not working in IE

I have this in my Angular.js controller that downloads a CSV file:

 var blob = new Blob([csvContent.join('')], { type: 'text/csv;charset=utf-8'});  var link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');  link.href = URL.createObjectURL(blob);  link.download = 'teams.csv';  link.click(); 

This works perfectly in Chrome but not in IE. A browser console log says:

HTML7007: One or more blob URLs were revoked by closing the blob for which they were created. These URLs will no longer resolve as the data backing the URL has been freed.

What does it mean and how can I fix it?

like image 560
raberana Avatar asked Dec 01 '13 09:12

raberana


1 Answers

Try this using, this or useragent

if (navigator.appVersion.toString().indexOf('.NET') > 0)         window.navigator.msSaveBlob(blob, filename); else {  var blob = new Blob(['stringhere'], { type: 'text/csv;charset=utf-8' });  var link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');  link.href = URL.createObjectURL(blob);  link.download = 'teams.csv';  link.click(); } 
like image 59
Naim Sulejmani Avatar answered Sep 18 '22 16:09

Naim Sulejmani