Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a blob object in new window

How can i display a Blob with pdf content immediately a new tab or have it displayed inline using an iframe?

in chrome and FF i can use something like this

var url = URL.createObjectURL(blob);
$('#uplFrame').attr('src', url);

but does not work in IE...i read online that IE is using the following for handeling blobs

window.navigator.msSaveOrOpenBlob(blob, "filename");

however this will ask the user if he wants to save or open the file in a new window. is it possible to let the code open the blob this automatically?

or is there a similar solution for the "createObjectURL" that does work for IE?

like image 214
jstrail Avatar asked Nov 10 '22 06:11

jstrail


1 Answers

For security reason and implementation the operation is not allowed in IE so the team build a specific API for asking permissions:

  // Save the blob1 content to a file, giving just a "Save" option
  window.navigator.msSaveBlob(blob1, 'msSaveBlob_testFile.txt'); 

  // Save the blob2 content to a file, giving both "Save" *and* "Open" options
  window.navigator.msSaveOrOpenBlob(blob2, 'msSaveBlobOrOpenBlob_testFile.txt');

Ref: https://msdn.microsoft.com/library/hh673542(v=vs.85).aspx

like image 123
Irvin Dominin Avatar answered Nov 14 '22 22:11

Irvin Dominin