如何在新标签页IE 11中打开Blob文件

时间:2018-07-11 06:40:39

标签: javascript angular typescript

我正在从事Angular5项目,面临IE浏览器中的一个问题。
我正在尝试下载pdf文件并在新标签页中打开。它在Chrome和Firefox中工作正常,但在IE中却无法正常工作。参见下面的代码

doDownload(blob: Blob,fileName:string){
 if (window.navigator.msSaveOrOpenBlob) {
  window.navigator.msSaveOrOpenBlob(blob, fileName);
 } else {
   var a = window.document.createElement('a');
   a.href = window.URL.createObjectURL(blob);
   a.download = fileName;
   document.body.appendChild(a);
   a.click();
   document.body.removeChild(a);
   window.open(a.href);
  }
}

在IE中,下载正在运行,但无法在新标签页中打开。

0 个答案:

没有答案