0

I am trying to use windows.open to open a pdf in new tab on clicking download.it is working in chrome but not in IE in angular app

showFile(blob){

  var newBlob = new Blob([blob], {type: "application/pdf"})
 //For IE
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveOrOpenBlob(newBlob);
    return;
  } 

  // For other browsers: 

  const data = window.URL.createObjectURL(newBlob);
  var link = document.createElement('a');
  link.href = data;
  link.download="file.pdf";
  link.click();
 window.open(link,'_blank);
}
S8321
  • 37
  • 1
  • 6

1 Answers1

0

IE doesn't have a native PDF viewer, so unless acrobat is installed, even a new window with the PDf will trigger a download.

Regardless, IE doesn't support opening a blob in a new window. You could create an iframe and pass the blob in as it's source and it might work, but IE being what IE is, that's not guaranteed.

The James
  • 465
  • 2
  • 9