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?
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?
Share Improve this question asked Aug 20, 2015 at 16:25 jstrailjstrail 491 gold badge1 silver badge2 bronze badges 2- 2 I think you'd need to create a temp file on the server to open it in a new window or tab using the browser. To serve a new document your server needs a file to server from, but if you can temporarily cache it on your server you can open the pdf directly in the browser no problem. – DrewT Commented Aug 20, 2015 at 16:33
-
1
According to MDN,
URL.createObjectURL(blob)
is supported in IE10 and up, but OP doesn't mention IE version. – EternalHour Commented Sep 26, 2019 at 20:45
1 Answer
Reset to default 1For 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./library/hh673542(v=vs.85).aspx
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745252812a4618779.html
评论列表(0条)