Andrew Gray Andrew Gray - 1 year ago 563
Javascript Question

"Access is Denied" when attempting to open a URL generated for a procedurally-generated PDF in IE11

For an application I am working on, we have a feature where we are generating a report for an object on the server side, and opening it in a new tab (for the time being) on the client.

I'm using the

function to make a URL for a
, which is comprised of the results of an AJAX call. Whenever a
call is made, however, I recieve a JavaScript error.


(function() {
angular.module('app').controller('someCtrl', [
'$window', 'someSvc', controller

function controller($window, someSvc) {
var vm = this;
vm.thing = {}; // How we get the object is unimportant for this question.
vm.printThing = printThing;

function printThing() {
someSvc.printThing(, vm.someFlag)
.then(function(result) {
var file = new Blob([result], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);



(function () {
angular.module('app').factory('someSvc', [
'$http', someSvc

function someSvc($http) {
var service = {
printThing: function(thingId, someFlag) {
var args = {
'thingId': thingId,
'someFlag': someFlag

return $http.get('/Reports/SomeReport', { 'params': args });

return service;

The server side code is unimportant to this question.

Question: Why is it that in my controller code, I get the error message,
0x80070005 - JavaScript runtime error: Access is denied.
in IE11? Additionally, in what way can I avoid the Access Is Denied error?

Answer Source

IE won't allow you to open blobs directly. You have to use msSaveOrOpenBlob. There's also msSaveBlob.

if (window.navigator && window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveOrOpenBlob(blob, fileName);
} else {
    var objectUrl = URL.createObjectURL(blob);;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download