Inside JavaScript I am making an XMLHttpRequest to a server which generates a PDF and returns the PDF data. In Chrome I'm able to open this data in a new window/tab like this:
window.open( URL.createObjectURL(RETURNED_DATA) );
where RETURNED_DATA is the actual data returned from the XHR.
In IE10 (and I'm assuming older versions of IE), I'm getting "Permission denied" when attempting to window.open()
with the DOMString
object returned from URL.createObjectURL()
I've tried various versions of this such as opening the new window before sending the XHR and updating the new window's location in the XHR callback, and opening the new window with a simple HTML file that just contains the XHR so that it can update it's own location in the XHR callback. All of these variations work in Chrome but result in "Permission denied" errors in IE10.
My best guess is that it's caused by the same-origin policy. When logging the DOMString
object to the console in Chrome vs IE, I've noticed that Chrome prepends the string with protocol and host so blob:http://localhost:8080/BLOB_DATA
whereas IE10 just has blob:BLOB_DATA
.
Any ideas how to resolve this issue in IE?
Open and Display PDFs from a Blob Using JavaScript. const documentBlobObjectUrl = URL. createObjectURL(blob); PSPDFKit. load({ document: documentBlobObjectUrl }) .
Convert PDF to Blob A Blob (or Binary Large Object) is an array of binary data.
XMLHttpRequest (XHR) objects are used to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. XMLHttpRequest is used heavily in AJAX programming.
If you cannot open your BLOB file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a BLOB file directly in the browser: Just drag the file onto this browser window and drop it.
For IE 10 and 11 you can use msSaveOrOpenBlob
window.navigator.msSaveOrOpenBlob(blob, fileName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With