I'm admittedly an AngularJS newbie but I can't find why this code works in Chrome and Firefox but gives "Access is denied"
in the javascript console with IE 11.
I need to display a PDF via an authenticated REST call. Ideally this would be displayed in a popup (preview) kind of window.
Code thus far looks like:
$http.post( url, payload, {
headers : {
"Authorization": token
},
responseType: "arraybuffer"
}).success(function ( data ) {
var file = new Blob( [ data ], { type: 'application/pdf' });
var fileURL = URL.createObjectURL( file );
window.open( fileURL );
}
The window.open()
gives the "access is denied"
message for IE11, but works in Chrome and Firefox. I tried changing to window.location()
, and got the same error.
This isn't a cross-domain issue (everything is in the same foo.net domain).
Saving text in a local file in Internet Explorer 10
It looks like IE blocks window.open on blobs, but implemented their own functions for opening and saving blobs. Instead try
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob);
}
else {
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}
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