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);
}