对于我正在开发的应用程序,我们有一个功能,可以在服务器端为对象生成报告,并在客户端的新选项卡(暂时)中打开它。
我正在使用URL.createObjectURL
函数创建一个 URLBlob
,它由 AJAX 调用的结果组成。每当一个$window.open(generatedFileUrl)
但是,我收到了 JavaScript 错误。
控制器:
(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.thing.id, vm.someFlag)
.then(function(result) {
var file = new Blob([result], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
$window.open(fileURL);
});
}
}
)();
Service:
(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;
}
})();
服务器端代码对于这个问题并不重要。
问题:为什么在我的控制器代码中,我收到错误消息,0x80070005 - JavaScript runtime error: Access is denied.
在IE11中?另外,如何避免访问被拒绝错误?